Skip to content

Commit

Permalink
Integrating Warp Payload Types into AvalancheGo for Cross-VM Compatib…
Browse files Browse the repository at this point in the history
  • Loading branch information
nytzuga committed Sep 29, 2023
1 parent 7a68f01 commit 8bd462d
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 328 deletions.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ require (
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
github.com/google/renameio/v2 v2.0.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/graph-gophers/graphql-go v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
Expand Down Expand Up @@ -156,3 +157,5 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/ava-labs/avalanchego => github.com/ava-labs/avalanchego v1.10.12-0.20230929062838-c67537f30776
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanche-network-runner v1.7.2 h1:XFad/wZfYzDnqbLzPAPPRYU3a1Zc8QT8x5dtLTS3lUo=
github.com/ava-labs/avalanche-network-runner v1.7.2/go.mod h1:naLveusSrP7YgTAqRykD1SyLOAUilCp9jGjk3MDxoPI=
github.com/ava-labs/avalanchego v1.10.10 h1:EYX4LVotcfdtIQ0nJSBTcoisubx/Bzk2tM1aP3yiYiw=
github.com/ava-labs/avalanchego v1.10.10/go.mod h1:6UA0nxxTvvpyuCbP2DSzx9+7uWQfQx9DPApK8JptLiE=
github.com/ava-labs/avalanchego v1.10.12-0.20230929062838-c67537f30776 h1:dOS/yfHnLYi198wHGYKWWYyu/lcdj3Ijg4qi3Hd+HsY=
github.com/ava-labs/avalanchego v1.10.12-0.20230929062838-c67537f30776/go.mod h1:1bhtTwb+6vthA/dzImBJFpCJGKx3wDZrIxx//1Yhuzw=
github.com/ava-labs/coreth v0.12.5-rc.6 h1:OajGUyKkO5Q82XSuMa8T5UD6QywtCHUiZ4Tv3RFmRBU=
github.com/ava-labs/coreth v0.12.5-rc.6/go.mod h1:s5wVyy+5UCCk2m0Tq3jVmy0UqOpKBDYqRE13gInCJVs=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
Expand Down Expand Up @@ -322,6 +322,8 @@ github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLe
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 h1:4/hN5RUoecvl+RmJRE2YxKWtnnQls6rQjjW5oV7qg2U=
github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/renameio/v2 v2.0.0 h1:UifI23ZTGY8Tt29JbYFiuyIU3eX+RNFtUwefq9qAhxg=
github.com/google/renameio/v2 v2.0.0/go.mod h1:BtmJXm5YlszgC+TD4HOEEUFgkJP3nLxehU6hfe7jRt4=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
Expand Down
4 changes: 2 additions & 2 deletions plugin/evm/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"

"github.com/ava-labs/avalanchego/warp/payload"
"github.com/ava-labs/subnet-evm/core"
"github.com/ava-labs/subnet-evm/core/rawdb"
"github.com/ava-labs/subnet-evm/core/types"
"github.com/ava-labs/subnet-evm/params"
"github.com/ava-labs/subnet-evm/precompile/precompileconfig"
"github.com/ava-labs/subnet-evm/precompile/results"
"github.com/ava-labs/subnet-evm/utils/predicate"
"github.com/ava-labs/subnet-evm/warp/payload"
"github.com/ava-labs/subnet-evm/x/warp"

"github.com/ava-labs/avalanchego/ids"
Expand Down Expand Up @@ -133,7 +133,7 @@ func (b *Block) handlePrecompileAccept(rules *params.Rules, sharedMemoryWriter *

// If Warp is enabled, add the block hash as an unsigned message to the warp backend.
if rules.IsPrecompileEnabled(warp.ContractAddress) {
blockHashPayload, err := payload.NewBlockHashPayload(b.ethBlock.Hash())
blockHashPayload, err := payload.NewBlockHashPayload(ids.ID(b.ethBlock.Hash().Bytes()))
if err != nil {
return fmt.Errorf("failed to create block hash payload: %w", err)
}
Expand Down
12 changes: 6 additions & 6 deletions plugin/evm/vm_warp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/vms/components/chain"
avalancheWarp "github.com/ava-labs/avalanchego/vms/platformvm/warp"
warpPayload "github.com/ava-labs/avalanchego/warp/payload"
"github.com/ava-labs/subnet-evm/core"
"github.com/ava-labs/subnet-evm/core/rawdb"
"github.com/ava-labs/subnet-evm/core/types"
Expand All @@ -29,7 +30,6 @@ import (
"github.com/ava-labs/subnet-evm/precompile/contract"
subnetEVMUtils "github.com/ava-labs/subnet-evm/utils"
predicateutils "github.com/ava-labs/subnet-evm/utils/predicate"
warpPayload "github.com/ava-labs/subnet-evm/warp/payload"
"github.com/ava-labs/subnet-evm/x/warp"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestValidateWarpMessage(t *testing.T) {
sourceAddress := common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2")
payload := []byte{1, 2, 3}
addressedPayload, err := warpPayload.NewAddressedPayload(
sourceAddress,
sourceAddress.Bytes(),
payload,
)
require.NoError(err)
Expand All @@ -158,7 +158,7 @@ func TestValidateInvalidWarpMessage(t *testing.T) {
sourceAddress := common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2")
payload := []byte{1, 2, 3}
addressedPayload, err := warpPayload.NewAddressedPayload(
sourceAddress,
sourceAddress.Bytes(),
payload,
)
require.NoError(err)
Expand All @@ -179,7 +179,7 @@ func TestValidateWarpBlockHash(t *testing.T) {
require := require.New(t)
sourceChainID := ids.GenerateTestID()
blockHash := ids.GenerateTestID()
blockHashPayload, err := warpPayload.NewBlockHashPayload(common.Hash(blockHash))
blockHashPayload, err := warpPayload.NewBlockHashPayload(blockHash)
require.NoError(err)
unsignedMessage, err := avalancheWarp.NewUnsignedMessage(testNetworkID, sourceChainID, blockHashPayload.Bytes())
require.NoError(err)
Expand All @@ -200,7 +200,7 @@ func TestValidateInvalidWarpBlockHash(t *testing.T) {
require := require.New(t)
sourceChainID := ids.GenerateTestID()
blockHash := ids.GenerateTestID()
blockHashPayload, err := warpPayload.NewBlockHashPayload(common.Hash(blockHash))
blockHashPayload, err := warpPayload.NewBlockHashPayload(blockHash)
require.NoError(err)
unsignedMessage, err := avalancheWarp.NewUnsignedMessage(testNetworkID, sourceChainID, blockHashPayload.Bytes())
require.NoError(err)
Expand Down Expand Up @@ -394,7 +394,7 @@ func TestReceiveWarpMessage(t *testing.T) {
payload := utils.RandomBytes(100)

addressedPayload, err := warpPayload.NewAddressedPayload(
testEthAddrs[0],
testEthAddrs[0].Bytes(),
payload,
)
require.NoError(err)
Expand Down
44 changes: 0 additions & 44 deletions warp/payload/README.md

This file was deleted.

60 changes: 0 additions & 60 deletions warp/payload/addressed_payload.go

This file was deleted.

57 changes: 0 additions & 57 deletions warp/payload/block_hash_payload.go

This file was deleted.

43 changes: 0 additions & 43 deletions warp/payload/codec.go

This file was deleted.

Loading

0 comments on commit 8bd462d

Please sign in to comment.