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

feat: add new fork block and precompile contract for BEP294 and BEP299 #2047

Merged
merged 36 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
030e416
feat: add new fork block and precompile contract for BEP294 and BEP29…
pythonberg1997 Nov 30, 2023
d3f882d
chore: update contracts code (#2024)
pythonberg1997 Dec 4, 2023
5743b06
feat: add `generate-proof` to geth cmd (#2028)
pythonberg1997 Dec 5, 2023
3e9e642
Merge remote-tracking branch 'BNBChain/develop' into bc-fusion
pythonberg1997 Dec 7, 2023
8f3c525
chore: resolve merge conflicts and fix review comments
pythonberg1997 Dec 8, 2023
3414e56
Merge pull request #2048 from Pythonberg1997/bc-fusion
unclezoro Dec 8, 2023
6744d7c
chore: modify breath block interval for test (#2054)
pythonberg1997 Dec 11, 2023
ab8793a
fix: bug in determining breathe block (#2055)
pythonberg1997 Dec 12, 2023
94b6815
chore: update logic of determining breathe block and returned data of…
pythonberg1997 Dec 12, 2023
d4f7313
chore: remove unused code (#2061)
pythonberg1997 Dec 13, 2023
6685f68
chore: fix CI issues (#2085)
pythonberg1997 Dec 19, 2023
08f75ca
chore: update system contracts' byte code (#2093)
pythonberg1997 Dec 20, 2023
167da21
Merge branch 'develop' into merge
pythonberg1997 Dec 21, 2023
c0df5e7
chore: add new byte code of `TokenHub` and `GovHub` to Feynman upgrade
pythonberg1997 Dec 21, 2023
aab5ad9
Merge pull request #2096 from Pythonberg1997/bc-fusion
unclezoro Dec 21, 2023
432085e
fix: avoid update validators on Feynman block (#2102)
pythonberg1997 Dec 25, 2023
e582264
chore: add `SystemTxsGas` for Feynman upgrade (#2133)
pythonberg1997 Jan 4, 2024
64a57a3
chore: update abi and bytecode (#2137)
pythonberg1997 Jan 8, 2024
7466f0a
Merge branch 'develop' into bc-fusion
pythonberg1997 Jan 8, 2024
85c6750
Merge pull request #2138 from Pythonberg1997/bc-fusion
unclezoro Jan 8, 2024
e2e2ac7
chore: fix lint issue (#2139)
pythonberg1997 Jan 8, 2024
7ade1d2
fix: compare headers' number in Big.Int rather than Uint64 (#2158)
pythonberg1997 Jan 15, 2024
13f17f2
fix: adjusted the timing of `UpgradeBuildInSystemContract` (#2166)
pythonberg1997 Jan 22, 2024
65baf18
chore: update the contracts' byte code of Feynman upgrade (#2175)
pythonberg1997 Jan 22, 2024
818379d
fix: upgrade system contracts twice issue in `traceBlockParallel` (#2…
pythonberg1997 Jan 25, 2024
7f6c4cd
Merge remote-tracking branch 'BNB-chain/develop' into bc-fusion-roshan
pythonberg1997 Jan 30, 2024
2f0b2f0
chore: resolve merge conflicts and fix review comments
pythonberg1997 Jan 30, 2024
fc9230e
Merge pull request #2192 from Pythonberg1997/bc-fusion
unclezoro Jan 30, 2024
d7e7f73
chore: add initialize for TokenRecoverPortalContract (#2194)
pythonberg1997 Feb 1, 2024
e7cd04b
fix: add check for block number (#2199)
pythonberg1997 Feb 2, 2024
fd0ee7d
fix: adjust the timing of initializing Feynman system contracts (#2203)
pythonberg1997 Feb 4, 2024
9e4d15b
fix: change the wrong precompile contract (#2206)
unclezoro Feb 5, 2024
a2ddb75
chore: update bls generate-proof cmd (#2215)
pythonberg1997 Feb 16, 2024
316585b
ci: add nancy job (#2221)
j75689 Feb 19, 2024
70adb60
fix the double sign testcase
unclezoro Feb 19, 2024
0574452
upgrade: update testnet contracts bytecode and hardfork time for Feyn…
pythonberg1997 Feb 26, 2024
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
4 changes: 1 addition & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ on:
- develop

pull_request:
branches:
- master
- develop

unclezoro marked this conversation as resolved.
Show resolved Hide resolved

jobs:
unit-test:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/commit-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ on:
- develop

pull_request:
branches:
- master
- develop


jobs:
commitlint:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:
- develop

pull_request:
branches:
- master
- develop

jobs:
truffle-test:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ on:
- develop

pull_request:
branches:
- master
- develop

unclezoro marked this conversation as resolved.
Show resolved Hide resolved

jobs:
golang-lint:
Expand Down Expand Up @@ -44,7 +42,7 @@ jobs:
${{ runner.os }}-go-

- run: |
go mod download
go mod tidy

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ on:
- develop

pull_request:
branches:
- master
- develop


jobs:
unit-test:
Expand Down Expand Up @@ -50,6 +48,6 @@ jobs:
ANDROID_HOME: "" # Skip android test
run: |
git submodule update --init --depth 1 --recursive
go mod download
go mod tidy
make test

2 changes: 1 addition & 1 deletion accounts/abi/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2127,7 +2127,7 @@ func TestGolangBindings(t *testing.T) {
t.Fatalf("failed to replace binding test dependency to current source tree: %v\n%s", err, out)
}

replacer = exec.Command(gocmd, "mod", "edit", "-x", "-require", "github.com/tendermint/[email protected]", "-replace", "github.com/tendermint/tendermint=github.com/bnb-chain/[email protected].15") // Repo root
replacer = exec.Command(gocmd, "mod", "edit", "-x", "-require", "github.com/tendermint/[email protected]", "-replace", "github.com/tendermint/tendermint=github.com/bnb-chain/[email protected].16") // Repo root
replacer.Dir = pkg
if out, err := replacer.CombinedOutput(); err != nil {
t.Fatalf("failed to replace tendermint dependency to bnb-chain source: %v\n%s", err, out)
Expand Down
107 changes: 103 additions & 4 deletions cmd/geth/blsaccountcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"math/big"
"os"
"path/filepath"
"strings"
Expand All @@ -15,6 +16,7 @@ import (
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
"github.com/prysmaticlabs/prysm/v4/io/prompt"
"github.com/prysmaticlabs/prysm/v4/proto/eth/service"
validatorpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1/validator-client"
"github.com/prysmaticlabs/prysm/v4/validator/accounts"
"github.com/prysmaticlabs/prysm/v4/validator/accounts/iface"
"github.com/prysmaticlabs/prysm/v4/validator/accounts/petnames"
Expand All @@ -26,6 +28,7 @@ import (

"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/signer/core"
)

Expand All @@ -45,10 +48,14 @@ var (
Name: "show-private-key",
Usage: "Show the BLS12-381 private key you will encrypt into a keystore file",
}
BLSAccountPasswordFileFlag = &cli.StringFlag{
blsAccountPasswordFileFlag = &cli.StringFlag{
Name: "blsaccountpassword",
Usage: "File path for the BLS account password, which contains the password to encrypt private key into keystore file for managing votes in fast_finality feature",
}
chainIdFlag = &cli.Int64Flag{
Name: "chain-id",
Usage: "The chain id of the network that the validator will be created at",
}
)

var (
Expand Down Expand Up @@ -133,7 +140,7 @@ Make sure you backup your BLS keys regularly.`,
privateKeyFlag,
showPrivateKeyFlag,
utils.BLSPasswordFileFlag,
BLSAccountPasswordFileFlag,
blsAccountPasswordFileFlag,
},
Description: `
geth bls account new
Expand All @@ -154,7 +161,7 @@ You must remember this password to unlock your account in the future.`,
Flags: []cli.Flag{
utils.DataDirFlag,
utils.BLSPasswordFileFlag,
BLSAccountPasswordFileFlag,
blsAccountPasswordFileFlag,
},
Description: `
geth bls account import <keyFile>
Expand Down Expand Up @@ -193,6 +200,22 @@ Print summary of existing BLS accounts in the current BLS wallet.`,

Delete the selected BLS account from the BLS wallet.`,
},
{
Name: "generate-proof",
Usage: "Generate ownership proof for the selected BLS account from the BLS wallet",
Action: blsAccountGenerateProof,
ArgsUsage: "<BLS pubkey>",
Category: "BLS ACCOUNT COMMANDS",
Flags: []cli.Flag{
utils.DataDirFlag,
utils.BLSPasswordFileFlag,
chainIdFlag,
},
Description: `
geth bls account generate-proof

Generate ownership proof for the selected BLS account from the BLS wallet. The proof is used to prove the ownership of the BLS account when creating validator on BSC after feynman upgrade.`,
pythonberg1997 marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
},
Expand Down Expand Up @@ -599,6 +622,82 @@ func blsAccountDelete(ctx *cli.Context) error {
return nil
}

// blsAccountGenerateProof generate ownership proof for a selected BLS account.
func blsAccountGenerateProof(ctx *cli.Context) error {
if ctx.Args().Len() == 0 {
utils.Fatalf("No BLS account specified.")
}
var filteredPubKeys []bls.PublicKey
for _, str := range ctx.Args().Slice() {
pkString := str
if strings.Contains(pkString, "0x") {
pkString = pkString[2:]
}
pubKeyBytes, err := hex.DecodeString(pkString)
if err != nil {
utils.Fatalf("Could not decode string %s as hex.", pkString)
}
blsPublicKey, err := bls.PublicKeyFromBytes(pubKeyBytes)
if err != nil {
utils.Fatalf("%#x is not a valid BLS public key.", pubKeyBytes)
}
filteredPubKeys = append(filteredPubKeys, blsPublicKey)
}
if len(filteredPubKeys) > 1 {
utils.Fatalf("Only support one BLS account specified.")
}
pubkeyBz := filteredPubKeys[0].Marshal()

cfg := gethConfig{Node: defaultNodeConfig()}
// Load config file.
if file := ctx.String(configFileFlag.Name); file != "" {
if err := loadConfig(file, &cfg); err != nil {
utils.Fatalf("%v", err)
}
}
utils.SetNodeConfig(ctx, &cfg.Node)

walletDir := filepath.Join(cfg.Node.DataDir, BLSWalletPath)
dirExists, err := wallet.Exists(walletDir)
if err != nil || !dirExists {
utils.Fatalf("BLS wallet not exists.")
}

walletPassword := utils.GetPassPhraseWithList("Enter the password for your BLS wallet.", false, 0, GetBLSPassword(ctx))
w, err := wallet.OpenWallet(context.Background(), &wallet.Config{
WalletDir: walletDir,
WalletPassword: walletPassword,
})
if err != nil {
utils.Fatalf("Open BLS wallet failed: %v.", err)
}
km, err := w.InitializeKeymanager(context.Background(), iface.InitKeymanagerConfig{ListenForChanges: false})
if err != nil {
utils.Fatalf("Initialize key manager failed: %v.", err)
}

chainIdInt64 := ctx.Int64(chainIdFlag.Name)
if chainIdInt64 == 0 {
utils.Fatalf("Chain id is required.")
}
chainId := new(big.Int).SetInt64(chainIdInt64)
paddedChainIdBytes := make([]byte, 32)
copy(paddedChainIdBytes[32-len(chainId.Bytes()):], chainId.Bytes())
msgHash := crypto.Keccak256(append(pubkeyBz, paddedChainIdBytes...))

req := &validatorpb.SignRequest{
PublicKey: pubkeyBz,
SigningRoot: msgHash,
}
sig, err := km.Sign(context.Background(), req)
if err != nil {
utils.Fatalf("Generate signature failed: %v.", err)
}
fmt.Printf("Proof: %#x\n", sig.Marshal())

return nil
}

func GetBLSPassword(ctx *cli.Context) []string {
path := ctx.String(utils.BLSPasswordFileFlag.Name)
if path == "" {
Expand All @@ -612,7 +711,7 @@ func GetBLSPassword(ctx *cli.Context) []string {
}

func GetBLSAccountPassword(ctx *cli.Context) []string {
path := ctx.String(BLSAccountPasswordFileFlag.Name)
path := ctx.String(blsAccountPasswordFileFlag.Name)
if path == "" {
return nil
}
Expand Down
Loading