Skip to content

Commit

Permalink
Merge pull request #11565 from vegaprotocol/feature/staking-bridge-th…
Browse files Browse the repository at this point in the history
…ings

chore: rename staking bridge events
  • Loading branch information
jeremyletang authored Aug 16, 2024
2 parents 96f74e1 + 884b777 commit f9a5a29
Show file tree
Hide file tree
Showing 18 changed files with 1,353 additions and 712 deletions.
6 changes: 3 additions & 3 deletions core/assets/erc20/erc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (e *ERC20) SignListAsset() (msg []byte, sig []byte, err error) {
}

source := e.asset.Details.GetERC20()
bundle, err := bridges.NewERC20Logic(e.wallet, bridgeAddress, e.chainID, e.ethClient.IsEthereum()).
bundle, err := bridges.NewERC20Logic(e.wallet, bridgeAddress, e.chainID, false).
ListAsset(e.address, e.asset.ID, source.LifetimeLimit, source.WithdrawThreshold, nonce)
if err != nil {
return nil, nil, err
Expand All @@ -156,7 +156,7 @@ func (e *ERC20) SignListAsset() (msg []byte, sig []byte, err error) {

func (e *ERC20) SignSetAssetLimits(nonce *num.Uint, lifetimeLimit *num.Uint, withdrawThreshold *num.Uint) (msg []byte, sig []byte, err error) {
bridgeAddress := e.ethClient.CollateralBridgeAddress().Hex()
bundle, err := bridges.NewERC20Logic(e.wallet, bridgeAddress, e.chainID, e.ethClient.IsEthereum()).
bundle, err := bridges.NewERC20Logic(e.wallet, bridgeAddress, e.chainID, false).
SetAssetLimits(e.address, lifetimeLimit, withdrawThreshold, nonce)
if err != nil {
return nil, nil, err
Expand All @@ -173,7 +173,7 @@ func (e *ERC20) SignWithdrawal(
) (msg []byte, sig []byte, err error) {
nonce, _ := num.UintFromBig(withdrawRef)
bridgeAddress := e.ethClient.CollateralBridgeAddress().Hex()
bundle, err := bridges.NewERC20Logic(e.wallet, bridgeAddress, e.chainID, e.ethClient.IsEthereum()).
bundle, err := bridges.NewERC20Logic(e.wallet, bridgeAddress, e.chainID, false).
WithdrawAsset(e.address, amount, ethPartyAddress, now, nonce)
if err != nil {
return nil, nil, err
Expand Down
6 changes: 2 additions & 4 deletions core/assets/erc20/erc20_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ func testWithdrawAsset(t *testing.T) {
assert.NotNil(t, msg)
assert.NotNil(t, sig)
assert.True(t, verifySignature(msg, sig))
assert.Equal(t,
"68154aa30a66d8546a338e2f50ac3e0bde710975755562e12c8508c5e4e43aa741b98d1f7384d8cf6a33e86fc1ed6f833ad627a9fb9b5a56aaaf0024511a2402",
assert.Equal(t, "4b7423e2f005a25150f56fdcea72ccabfb466d94a4a3d1aa3541eed2f1292deabd9de643ccc00d64561806c302c8c9773a028fd0e2778e2b2a6f6b3948c95b06",
hex.EncodeToString(sig),
)
}
Expand All @@ -113,8 +112,7 @@ func testListAsset(t *testing.T) {
assert.NotNil(t, msg)
assert.NotNil(t, sig)
assert.True(t, verifySignature(msg, sig))
assert.Equal(t,
"e6048f597145d7d1e1ddfe41abf9ae950e9b6e93598c8b1e4fe2d9af8493b240a4d85322eb40c6bf76b0eac2481fa42014956f10a38675769b0c995e191d650b",
assert.Equal(t, "125419bebd3623144c1da43d9cc32fc7cab4b870ade32eda8e2a3b175c22b9dac556c47c195bf44f7d7114964411235e690294683cf252f005809f49c4536400",
hex.EncodeToString(sig),
)
}
Expand Down
4 changes: 2 additions & 2 deletions core/bridges/erc20_asset_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (e ERC20AssetPool) SetBridgeAddress(

newAddressEth := ethcmn.HexToAddress(newAddress)
buf, err := args.Pack([]interface{}{
newAddressEth, nonce.BigInt(), "set_bridge_address",
newAddressEth, nonce.BigInt(), "setBridgeAddress",
}...)
if err != nil {
return nil, fmt.Errorf("couldn't pack abi message: %w", err)
Expand Down Expand Up @@ -122,7 +122,7 @@ func (e ERC20AssetPool) SetMultiSigControl(

newAddressEth := ethcmn.HexToAddress(newAddress)
buf, err := args.Pack([]interface{}{
newAddressEth, nonce.BigInt(), "set_multisig_control",
newAddressEth, nonce.BigInt(), "setMultisigControl",
}...)
if err != nil {
return nil, fmt.Errorf("couldn't pack abi message: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions core/bridges/erc20_asset_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ func TestAssetPoolSetBridgeAddress(t *testing.T) {
{
name: "v1 scheme",
v1: true,
expected: "2488c05dd36a754db037f22a1d649109573e299a3c135efdb81c6f64632b26101c0b4ce19c896d370abae8d457682b21a4a3322f48380f29932b311b6ab47707",
expected: "d0d9cfac8f805bd28a8c534069157d900b8c60d29580ebbee73ad5be71d1d2c1b20d5f10339b0ff570cea9f3422c1c599bd76b99c37cd19c8a3901bd75603404",
},
{
name: "v2 scheme",
v1: false,
expected: "4b01dfa1a3b77ecc624f678805a74418862cbcb1e32b929e7dce7fbbfa73806ec1f5db1d40d28f4ebcb09d83f59815f04438142612ebc1683158a23c9fbf3a0c",
expected: "52e2d9005416e7afe750b4fcf69d9e8e0fe2809127f87c327f10cfa5e76da55069ef723cdc07bafcfb4e44798f2d1b52cf618787cbccf19c6c8f2d1cd0530906",
},
}

Expand Down
20 changes: 10 additions & 10 deletions core/bridges/erc20_logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (e ERC20Logic) ListAsset(
lifetimeLimit.BigInt(),
withdrawThreshold.BigInt(),
nonce.BigInt(),
"list_asset",
"listAsset",
}...)
if err != nil {
return nil, fmt.Errorf("couldn't pack abi message: %w", err)
Expand Down Expand Up @@ -182,7 +182,7 @@ func (e ERC20Logic) buildListAssetMessage(
lifetimeLimit.BigInt(),
withdrawThreshold.BigInt(),
nonce.BigInt(),
"list_asset",
"listAsset",
}...)
if err != nil {
return nil, fmt.Errorf("couldn't pack abi message: %w", err)
Expand Down Expand Up @@ -266,7 +266,7 @@ func (e ERC20Logic) RemoveAsset(

tokenAddressEth := ethcmn.HexToAddress(tokenAddress)
buf, err := args.Pack([]interface{}{
tokenAddressEth, nonce.BigInt(), "remove_asset",
tokenAddressEth, nonce.BigInt(), "removeAsset",
}...)
if err != nil {
return nil, fmt.Errorf("couldn't pack abi message: %w", err)
Expand Down Expand Up @@ -354,7 +354,7 @@ func (e ERC20Logic) buildWithdrawAssetMessage(
hexEthPartyAddress,
timestamp,
nonce.BigInt(),
"withdraw_asset",
"withdrawAsset",
}...)
if err != nil {
return nil, fmt.Errorf("couldn't pack abi message: %w", err)
Expand Down Expand Up @@ -447,7 +447,7 @@ func (e ERC20Logic) SetAssetLimits(
lifetimeLimit.BigInt(),
withdrawThreshold.BigInt(),
nonce.BigInt(),
"set_asset_limits",
"setAssetLimits",
}...)
if err != nil {
return nil, fmt.Errorf("couldn't pack abi message: %w", err)
Expand Down Expand Up @@ -509,7 +509,7 @@ func (e ERC20Logic) buildSetAssetLimitsMessage(
lifetimeLimit.BigInt(),
withdrawThreshold.BigInt(),
nonce.BigInt(),
"set_asset_limits",
"setAssetLimits",
}...)
if err != nil {
return nil, fmt.Errorf("couldn't pack abi message: %w", err)
Expand Down Expand Up @@ -604,7 +604,7 @@ func (e ERC20Logic) buildWithdrawDelayMessage(
buf, err := args.Pack([]interface{}{
delayBig,
nonce.BigInt(),
"set_withdraw_delay",
"setWithdrawDelay",
}...)
if err != nil {
return nil, fmt.Errorf("couldn't pack abi message: %w", err)
Expand Down Expand Up @@ -671,7 +671,7 @@ func (e ERC20Logic) GlobalStop(

buf, err := args.Pack([]interface{}{
nonce.BigInt(),
"global_stop",
"globalStop",
}...)
if err != nil {
return nil, fmt.Errorf("couldn't pack abi message: %w", err)
Expand Down Expand Up @@ -710,7 +710,7 @@ func (e ERC20Logic) GlobalResume(

buf, err := args.Pack([]interface{}{
nonce.BigInt(),
"global_resume",
"globalResume",
}...)
if err != nil {
return nil, fmt.Errorf("couldn't pack abi message: %w", err)
Expand Down Expand Up @@ -750,7 +750,7 @@ func (e ERC20Logic) VerifyGlobalResume(

buf, err := args.Pack([]interface{}{
nonce.BigInt(),
"global_resume",
"globalResume",
}...)
if err != nil {
return nil, fmt.Errorf("couldn't pack abi message: %w", err)
Expand Down
12 changes: 6 additions & 6 deletions core/bridges/erc20_logic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ func testListAsset(t *testing.T) {
{
name: "v1 scheme",
v1: true,
expected: "7df8b88552c2f981e64b13f1ce3ee5dcb71e8f59ec057010b7b469120afff7d479f234714785cfc605230dfb2d17f9cc7858143196a13f357ce008e3f3f78a00",
expected: "a39fa614b7b4bb0cf5819840164ca48472d1bda98a49053f891dfb004f053d2c29a60df5423927dad057f1d3d6a04c6e6d82f1bf128db5d5a7a01bcc8b70ab0e",
},
{
name: "v2 scheme",
v1: false,
expected: "03d8d648da4402bebd096f067cebf3e3b70f2c4e1cad6ca9eb757f554b6ca9efb84010887aeef543cf72cb5d78a741d0683befc6f5e0ca2d0347832232af610c",
expected: "d6810cef5534e232396ab0c572ca079fa41f728a20d98da3bfb59b81f183a96adee103d5f94348e9a8ce823446392109bc8bf10a27076cd0e232a1f808e0810c",
},
}

Expand Down Expand Up @@ -86,12 +86,12 @@ func testRemoveAsset(t *testing.T) {
{
name: "v1 scheme",
v1: true,
expected: "9012eb20763500caf1a4d7640470449c7220872d7136e17c70231c269051cf80e08760d60850578ebf494e24610a54225c7d994f15f57d9f451e8f717eb3f904",
expected: "a1c183d1c076c518297fa75f0fa3fddf6e5e83e76800a2efdbce36be12d4a23e2b61bce8097fea701f5a274ec89d70f92ffdd83a82a4d2c65f82b905109c3d0f",
},
{
name: "v2 scheme",
v1: false,
expected: "aa07e175a9a4c3dcb0f5dcbd24cc6636e699ee6a1daa9a80267cec8f0be130b86465fa56296743879f56d94d6be64a0b10b76bcee40d0d09ec078b2814b89500",
expected: "f11d5e0fa1c68edd1b43db30a0d02aaff8cef26c6140d30a4570615fa12a0e4e858a30b73a3763590a88614f366e9f433978653445b901e058dc07fe77595901",
},
}

Expand Down Expand Up @@ -122,12 +122,12 @@ func testWithdrawAsset(t *testing.T) {
{
name: "v1 scheme",
v1: true,
expected: "0ff08571ab504acdce063a5a5a00dd8878d64ccb09ea6887aacd1fd41b517cd13f4e12edfaa4d06fef5d24087ba9e7c980532daa0a6f1fa329b8d75961f4ab03",
expected: "8c70e1bb8a74a9112ef475cdca37f63149453f5d3729164847aabf329c8932774922bb3cf41dfd7112fa8a0bdbe3f845b170e8f38406ae51fd7da00177dbc807",
},
{
name: "v2 scheme",
v1: false,
expected: "9f2d7ec17059fd5d4697337a46899f73681dece748ea1342b3be24b5f34f0b934ad448f7e9bd3a113102d46d8433dd26458cf06c3fd7a1622d086faab1a77b08",
expected: "057bcb000d6961d4c8cd67f5a8a8ffac501f7077c23dcb4aab0127f1f4530e865d8627bccfb71559b9ddca0cb938b96c709fdf419d2f350ec9ab6416b888c70f",
},
}

Expand Down
10 changes: 5 additions & 5 deletions core/bridges/erc20_multisigcontrol.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (e *ERC20MultiSigControl) BurnNonce(
},
})

buf, err := args.Pack([]interface{}{nonce.BigInt(), "burn_nonce"}...)
buf, err := args.Pack([]interface{}{nonce.BigInt(), "burnNonce"}...)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -93,7 +93,7 @@ func (e *ERC20MultiSigControl) SetThreshold(

args := abi.Arguments([]abi.Argument{
{
Name: "new_threshold",
Name: "newThreshold",
Type: typU16,
},
{
Expand All @@ -106,7 +106,7 @@ func (e *ERC20MultiSigControl) SetThreshold(
},
})

buf, err := args.Pack([]interface{}{newThreshold, nonce.BigInt(), "set_threshold"}...)
buf, err := args.Pack([]interface{}{newThreshold, nonce.BigInt(), "setThreshold"}...)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -151,7 +151,7 @@ func (e *ERC20MultiSigControl) AddSigner(
})

newSignerAddr := ethcmn.HexToAddress(newSigner)
buf, err := args.Pack([]interface{}{newSignerAddr, nonce.BigInt(), "add_signer"}...)
buf, err := args.Pack([]interface{}{newSignerAddr, nonce.BigInt(), "addSigner"}...)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -197,7 +197,7 @@ func (e *ERC20MultiSigControl) RemoveSigner(
})

oldSignerAddr := ethcmn.HexToAddress(oldSigner)
buf, err := args.Pack([]interface{}{oldSignerAddr, nonce.BigInt(), "remove_signer"}...)
buf, err := args.Pack([]interface{}{oldSignerAddr, nonce.BigInt(), "removeSigner"}...)
if err != nil {
return nil, err
}
Expand Down
12 changes: 6 additions & 6 deletions core/bridges/erc20_multisigcontrol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ func testSetThreshold(t *testing.T) {
{
name: "v1 scheme",
v1: true,
expected: "a2c61b473f15a1729e8593d65748e7a9813102e0d7304598af556525206db599fb79b9750349c6cb564a2f3ecdf233dd19b1598302e0cb91218adff1c609ac09",
expected: "537eee3a9151d3f9a0a076c9521d3ca014efaefb20fd9be1b36c1e2475897f82b79b0de759b24a52a1a66c272c85628acd182a3cef2ae92b91a595f8d8123c06",
},
{
name: "v2 scheme",
v1: false,
expected: "aa79559d350a9b139d04d7883b7ec26b3948bba503fddcc55f8a868a69ef48dad32ffb4233a041401e482e71232fc339aa6deffda31bcd978596a6a0a6d64b0c",
expected: "e1bc702b74ca31f08d1d3534b6b147f641cf94713a809dd5b7ed5cb6e61b1892f1d2327ef14194bac488f41a661b805c6ca2f3daba7108eee46949229a126c0e",
},
}

Expand Down Expand Up @@ -84,12 +84,12 @@ func testAddSigner(t *testing.T) {
{
name: "v1 scheme",
v1: true,
expected: "7bdc018935610f23667b31d4eee248160ab39caa1e70ad20da49bf8971d5a16b30f71a09d9aaf5b532defdb7710d85c226e98cb90a49bc4b4401b33f3c5a1601",
expected: "52201353f14009c7638a6460af9340871de8d34a198d4957a142aa8098922829d4963eff0e6951fdecfe04566c865225b4c41dd2393b40d4de76fb9819142d0c",
},
{
name: "v2 scheme",
v1: false,
expected: "f86654970ab8aa7b8f1ac72cd1349cd667acd21b7ff2078653d488f3ab65a446df1b4878692d7f07e2f0111bed069fd7cf5c32f07ae88ed059624480cd0edd07",
expected: "67e5a71935eaf134f4cbfadbefa96e510c97d6198accfcec76b046ee46ecd59fe4ae6f371973a8f4be7a67dd20b38c421b0f24061f1c95fe1e9322d04997e407",
},
}

Expand Down Expand Up @@ -120,12 +120,12 @@ func testRemoveSigner(t *testing.T) {
{
name: "v1 scheme",
v1: true,
expected: "98ea2303c68dbb0a88bdb7dad8c6e2db9698cd992667399a378e682dbdf16e74a9d304a32e36b48de81c0e99449a7a37c1a7ef94af1e85aa88a808f8d7126c0c",
expected: "4bf8057aa87a4ec5049766b0eb40426c9ba0464cda2ce203d16c590f3153657689143161908923b0c6ab32dec57c4c5aca7e4aaef24b8d22362413908868ea00",
},
{
name: "v2 scheme",
v1: false,
expected: "e17efd360ce488a7299175473f257544391e3823db314e31cc69e6ae2730ead994e89bfab5813ea1379c4b6e499d131308ebe516ba6142f9f77479083685020b",
expected: "648f08b810bcbe589b79f7476f48de6e2c3528fbb059427f3876745dec51128952210d5e509e307d0dc2f6ba67f65bda7a28d96a8d31a365d04398cdde78150b",
},
}

Expand Down
24 changes: 0 additions & 24 deletions core/client/eth/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ func (c *PrimaryClient) UpdateEthereumConfig(ctx context.Context, ethConfig *typ
return fmt.Errorf("updated chain ID does not match the one set during start up, expected %v got %v", ethConfig.ChainID(), chainID)
}

if err := c.verifyCollateralContract(ctx, ethConfig); err != nil {
return fmt.Errorf("failed to verify collateral bridge contract: %w", err)
}

if err := c.verifyMultisigContract(ctx, ethConfig); err != nil {
return fmt.Errorf("failed to verify multisig control contract: %w", err)
}

c.ethConfig = ethConfig

return nil
Expand Down Expand Up @@ -171,19 +163,3 @@ func (c *PrimaryClient) VerifyContract(ctx context.Context, address ethcommon.Ad

return nil
}

func (c *PrimaryClient) verifyCollateralContract(ctx context.Context, ethConfig *types.EthereumConfig) error {
if address := ethConfig.CollateralBridge(); address.HasAddress() {
return c.VerifyContract(ctx, address.Address(), ContractHashes["collateral"])
}

return nil
}

func (c *PrimaryClient) verifyMultisigContract(ctx context.Context, ethConfig *types.EthereumConfig) error {
if address := ethConfig.MultiSigControl(); address.HasAddress() {
return c.VerifyContract(ctx, address.Address(), ContractHashes["multisig"])
}

return nil
}
Loading

0 comments on commit f9a5a29

Please sign in to comment.