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

Support Arbitrum bridge #10632

Merged
merged 18 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
bb0f0af
feat: Convert all assets to be associated to the configured Ethereum …
ValentinTrinque Feb 12, 2024
a95bcb9
fix: Value assets chain ID using network parameters
ValentinTrinque Feb 13, 2024
2795aa0
feat: Account for missing chain ID when deduplicating chain events
ValentinTrinque Feb 16, 2024
02848a7
feat: Introduce secondary ethereum client
ValentinTrinque Feb 14, 2024
cd83502
feat: Expose asset's chain ID
ValentinTrinque Mar 8, 2024
aec52b4
feat: implement multisig tracking and signature gen for second bridge
wwestgarth Mar 13, 2024
99db863
fix: Clean up unused tracked network parameters during protocol upgrade
ValentinTrinque Mar 12, 2024
6ad3e0e
fix: Determine protocol upgrade from context and not snapshot state
ValentinTrinque Mar 12, 2024
54362d5
feat: scaffold the hardcoded secondary ethereum configuration
ValentinTrinque Mar 12, 2024
183f70e
chore: improve doc-strings for add/remove signer sig-bundle API
wwestgarth Mar 13, 2024
83dca68
fix: issues with rebase
wwestgarth Mar 15, 2024
1efcf22
fix: save secondary bridge state in snapshot
wwestgarth Mar 15, 2024
4b7597a
fix: validate EVM chain ID in asset proposal earlier on in governance…
wwestgarth Mar 21, 2024
6eb269a
chore: apply suggestions from protos doc review
wwestgarth Mar 26, 2024
29c2bd8
fix: stage asset migration updates so that they get sent out on the n…
wwestgarth Mar 26, 2024
f7e9aab
chore: relax migration check until we know what version we are upgrad…
wwestgarth Mar 26, 2024
3bdc335
chore: rename network parameter for second bridge config
wwestgarth Mar 26, 2024
e907787
chore: rename spam network parameter
wwestgarth Mar 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@
- [10517](https://github.com/vegaprotocol/vega/issues/10517) - Add optional cap to metric based rewards.
- [10246](https://github.com/vegaprotocol/vega/issues/10246) - Add quantum volumes to teams statistics API.
- [10550](https://github.com/vegaprotocol/vega/issues/10550) - Update network parameters with default values.
- [10612](https://github.com/vegaprotocol/vega/issues/10612) - Convert all assets to be associated to the configured Ethereum chain.
- [10624](https://github.com/vegaprotocol/vega/issues/10624) - Ensure chain event are not duplicated when chain identifier is missing.
- [10623](https://github.com/vegaprotocol/vega/issues/10623) - Introduce secondary Ethereum client

### 🐛 Fixes

Expand Down
6 changes: 3 additions & 3 deletions cmd/vega/commands/announce_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (

"github.com/jessevdk/go-flags"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

type AnnounceNodeCmd struct {
Expand Down Expand Up @@ -203,8 +204,7 @@ func getNodeWalletCommander(log *logging.Logger, registryPass string, vegaPaths
return nil, nil, nil, fmt.Errorf("couldn't initialise ABCI client: %w", err)
}

coreClient, err := getCoreClient(
net.JoinHostPort(cfg.API.IP, strconv.Itoa(cfg.API.Port)))
coreClient, err := getCoreClient(net.JoinHostPort(cfg.API.IP, strconv.Itoa(cfg.API.Port)))
if err != nil {
return nil, nil, nil, fmt.Errorf("couldn't connect to node: %w", err)
}
Expand Down Expand Up @@ -232,7 +232,7 @@ func (h heightProvider) Height() uint64 {
}

func getCoreClient(address string) (api.CoreServiceClient, error) {
tdconn, err := grpc.Dial(address, grpc.WithInsecure())
tdconn, err := grpc.Dial(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, err
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/vega/commands/faucet/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ func (opts *faucetInit) Execute(_ []string) error {
nodeCfg.EvtForward.BlockchainQueueAllowlist = append(
nodeCfg.EvtForward.BlockchainQueueAllowlist, initResult.Wallet.PublicKey)

nodeCfg.SecondaryEvtForward.BlockchainQueueAllowlist = append(
nodeCfg.SecondaryEvtForward.BlockchainQueueAllowlist, initResult.Wallet.PublicKey)

if err := nodeCfgLoader.Save(nodeCfg); err != nil {
return fmt.Errorf("couldn't update node configuration: %w", err)
}
Expand Down
34 changes: 24 additions & 10 deletions cmd/vega/commands/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ type Command struct {

vegaPaths paths.Paths

ethClient *ethclient.Client
ethConfirmations *ethclient.EthereumConfirmations
l2Clients *ethclient.L2Clients
primaryEthClient *ethclient.PrimaryClient
primaryEthConfirmations *ethclient.EthereumConfirmations

secondaryEthClient *ethclient.SecondaryClient
secondaryEthConfirmations *ethclient.EthereumConfirmations

l2Clients *ethclient.L2Clients

abciApp *appW
protocol *protocol.Protocol
Expand Down Expand Up @@ -108,7 +112,7 @@ func (n *Command) Run(
}

if err := n.loadNodeWallets(); err != nil {
return err
return fmt.Errorf("could not load the node wallets: %w", err)
}

if err := n.startBlockchainClients(); err != nil {
Expand All @@ -125,8 +129,10 @@ func (n *Command) Run(
n.cancel,
n.stopBlockchain,
n.nodeWallets,
n.ethClient,
n.ethConfirmations,
n.primaryEthClient,
n.secondaryEthClient,
n.primaryEthConfirmations,
n.secondaryEthConfirmations,
n.blockchainClient,
vegaPaths,
n.stats,
Expand Down Expand Up @@ -450,7 +456,7 @@ func (n *Command) startBlockchainClients() error {
// We may not need ethereum client initialized when we have not
// provided the ethereum endpoint. We skip creating client here
// when RPCEnpoint is empty and the nullchain present.
if len(n.conf.Ethereum.RPCEndpoint) < 1 && n.conf.Blockchain.ChainProvider == blockchain.ProviderNullChain {
if n.conf.IsNullChain() && !n.conf.HaveEthClient() {
return nil
}

Expand All @@ -460,11 +466,19 @@ func (n *Command) startBlockchainClients() error {
return fmt.Errorf("could not instantiate ethereum l2 clients: %w", err)
}

n.ethClient, err = ethclient.Dial(n.ctx, n.conf.Ethereum)
n.primaryEthClient, err = ethclient.PrimaryDial(n.ctx, n.conf.Ethereum)
if err != nil {
return fmt.Errorf("could not instantiate primary ethereum client: %w", err)
}

n.secondaryEthClient, err = ethclient.SecondaryDial(n.ctx, n.conf.Ethereum)
if err != nil {
return fmt.Errorf("could not instantiate ethereum client: %w", err)
return fmt.Errorf("could not instantiate secondary ethereum client: %w", err)
}
n.ethConfirmations = ethclient.NewEthereumConfirmations(n.conf.Ethereum, n.ethClient, nil)

n.primaryEthConfirmations = ethclient.NewEthereumConfirmations(n.conf.Ethereum, n.primaryEthClient, nil)

n.secondaryEthConfirmations = ethclient.NewEthereumConfirmations(n.conf.Ethereum, n.secondaryEthClient, nil)

return nil
}
Expand Down
1 change: 1 addition & 0 deletions cmd/vega/commands/verify/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type asset struct {
ContractAddress string `json:"contract_address"`
LifetimeLimit string `json:"lifetime_limit"`
WithdrawThreshold string `json:"withdraw_threshold"`
ChainID string `json:"chain_id"`
} `json:"erc20,omitempty"`
}
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/vega/commands/verify/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func testVerifyERC20Assets(t *testing.T) {
Source: &assets.Source{
Erc20: &assets.Erc20{
ContractAddress: "0xBC944ba38753A6fCAdd634Be98379330dbaB3Eb8",
ChainID: "1",
},
},
}
Expand All @@ -112,6 +113,7 @@ func testVerifyERC20Assets(t *testing.T) {
Source: &assets.Source{
Erc20: &assets.Erc20{
ContractAddress: "invalid",
ChainID: "1",
},
},
}
Expand All @@ -124,6 +126,7 @@ func testVerifyERC20Assets(t *testing.T) {
Source: &assets.Source{
Erc20: &assets.Erc20{
ContractAddress: "0xF0a9b5d3a00b53362F9b73892124743BAaE526c4",
ChainID: "1",
},
},
}
Expand Down
4 changes: 4 additions & 0 deletions commands/issue_signatures.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,9 @@ func checkIssueSignatures(cmd *commandspb.IssueSignatures) Errors {
errs.AddForProperty("issue_signatures.kind", ErrIsNotValid)
}

if len(cmd.ChainId) == 0 {
errs.AddForProperty("issue_signatures.chain_id", ErrIsRequired)
}

return errs
}
4 changes: 4 additions & 0 deletions commands/proposal_submission.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,10 @@ func checkERC20AssetSource(s *protoTypes.AssetDetails_Erc20) Errors {

asset := s.Erc20

if len(asset.ChainId) == 0 {
errs.AddForProperty("proposal_submission.terms.change.new_asset.changes.source.erc20.chain_id", ErrIsRequired)
}

if len(asset.ContractAddress) == 0 {
errs.AddForProperty("proposal_submission.terms.change.new_asset.changes.source.erc20.contract_address", ErrIsRequired)
}
Expand Down
21 changes: 21 additions & 0 deletions commands/proposal_submission_new_asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestCheckProposalSubmissionForNewAsset(t *testing.T) {
t.Run("Submitting an built-in asset change with max faucet amount succeeds", testNewBuiltInAssetChangeSubmissionWithMaxFaucetAmountMintSucceeds)
t.Run("Submitting an built-in asset change with not-a-number max faucet amount fails", testNewBuiltInAssetChangeSubmissionWithNaNMaxFaucetAmountMintFails)
t.Run("Submitting an ERC20 asset change without ERC20 asset fails", testNewERC20AssetChangeSubmissionWithoutErc20AssetFails)
t.Run("Submitting an ERC20 asset change without chain id fails", testNewERC20AssetChangeSubmissionWithoutChainIDFails)
t.Run("Submitting an ERC20 asset change without contract address fails", testNewERC20AssetChangeSubmissionWithoutContractAddressFails)
t.Run("Submitting an ERC20 asset change with contract address succeeds", testNewERC20AssetChangeSubmissionWithContractAddressSucceeds)
t.Run("Submitting an ERC20 asset change with invalid lifetime limit fails", testNewERC20AssetChangeSubmissionWithInvalidLifetimeLimitFails)
Expand Down Expand Up @@ -358,6 +359,26 @@ func testNewERC20AssetChangeSubmissionWithoutErc20AssetFails(t *testing.T) {
assert.Contains(t, err.Get("proposal_submission.terms.change.new_asset.changes.source.erc20"), commands.ErrIsRequired)
}

func testNewERC20AssetChangeSubmissionWithoutChainIDFails(t *testing.T) {
err := checkProposalSubmission(&commandspb.ProposalSubmission{
Terms: &types.ProposalTerms{
Change: &types.ProposalTerms_NewAsset{
NewAsset: &types.NewAsset{
Changes: &types.AssetDetails{
Source: &types.AssetDetails_Erc20{
Erc20: &types.ERC20{
ChainId: "",
},
},
},
},
},
},
})

assert.Contains(t, err.Get("proposal_submission.terms.change.new_asset.changes.source.erc20.chain_id"), commands.ErrIsRequired)
}

func testNewERC20AssetChangeSubmissionWithoutContractAddressFails(t *testing.T) {
err := checkProposalSubmission(&commandspb.ProposalSubmission{
Terms: &types.ProposalTerms{
Expand Down
2 changes: 1 addition & 1 deletion core/api/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (s *coreService) updateConfig(conf Config) {

func (s *coreService) LastBlockHeight(
ctx context.Context,
req *protoapi.LastBlockHeightRequest,
_ *protoapi.LastBlockHeightRequest,
) (*protoapi.LastBlockHeightResponse, error) {
defer metrics.StartAPIRequestAndTimeGRPC("LastBlockHeight")()

Expand Down
Loading
Loading