Skip to content

Commit

Permalink
[AVAX] Post Merge fixes for Cortina 16 (v1.10.16)
Browse files Browse the repository at this point in the history
  • Loading branch information
evlekht committed Mar 8, 2024
1 parent 151c6ee commit 300ac8b
Show file tree
Hide file tree
Showing 28 changed files with 162 additions and 393 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/auto-generated-checker.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: Auto-Generated Code Checker
on:
push:
tags:
- "*"
branches:
- master
- dev
pull_request:
tags-ignore: ["*"]
branches: [chain4travel, dev]
push:
branches: [chain4travel, dev]
workflow_dispatch:
merge_group:
types: [checks_requested]

Expand Down
4 changes: 2 additions & 2 deletions genesis/camino_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ func buildPGenesis(config *Config, hrp string, xGenesisBytes []byte, xGenesisDat
stakingOffset += time.Duration(config.InitialStakeDurationOffset) * time.Second

platformvmArgs.Validators = append(platformvmArgs.Validators,
api.PermissionlessValidator{
Staker: api.Staker{
api.GenesisPermissionlessValidator{
GenesisValidator: api.GenesisValidator{
StartTime: json.Uint64(startStakingTime.Unix()),
EndTime: json.Uint64(endStakingTime.Unix()),
NodeID: platformAllocation.NodeID,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ require (

replace github.com/ava-labs/avalanche-ledger-go => github.com/chain4travel/camino-ledger-go v0.0.13-c4t

replace github.com/ava-labs/coreth => github.com/chain4travel/caminoethvm v1.1.15-rc1
replace github.com/ava-labs/coreth => github.com/chain4travel/caminoethvm v1.1.16-rc0
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/ledger-avalanche/go v0.0.0-20230105152938-00a24d05a8c7 h1:EdxD90j5sClfL5Ngpz2TlnbnkNYdFPDXa0jDOjam65c=
github.com/ava-labs/ledger-avalanche/go v0.0.0-20230105152938-00a24d05a8c7/go.mod h1:XhiXSrh90sHUbkERzaxEftCmUz53eCijshDLZ4fByVM=
github.com/ava-labs/ledger-avalanche/go v0.0.0-20231102202641-ae2ebdaeac34 h1:mg9Uw6oZFJKytJxgxnl3uxZOs/SB8CVHg6Io4Tf99Zc=
github.com/ava-labs/ledger-avalanche/go v0.0.0-20231102202641-ae2ebdaeac34/go.mod h1:pJxaT9bUgeRNVmNRgtCHb7sFDIRKy7CzTQVi8gGNT6g=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand Down Expand Up @@ -106,8 +106,8 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chain4travel/caminoethvm v1.1.15-rc1 h1:zZ3kcN0FJGTgmTnfw5drrb+V10wiR0tho/m3/Jy9iS0=
github.com/chain4travel/caminoethvm v1.1.15-rc1/go.mod h1:aXs2X5y4BVp+fGUk4sR1rk1qHmrtTl6NxTJPhUVw3P0=
github.com/chain4travel/caminoethvm v1.1.16-rc0 h1:yu2vadc5xzsQ6gtK7oNYBwVw+CsAVFvDj0894In71/M=
github.com/chain4travel/caminoethvm v1.1.16-rc0/go.mod h1:PgnbVryuhwq5IS7lI+TciNyqVPEru4gMOj3lzEBVPEE=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
Expand Down
4 changes: 2 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ func New(
if err := staking.ValidateCertificate(stakingCert); err != nil {
return nil, fmt.Errorf("invalid staking certificate: %w", err)
}

// Get the nodeID from certificate (secp256k1 public key)
nodeID, err := peer.CertToID(tlsCert)
if err != nil {
return fmt.Errorf("cannot extract nodeID from certificate: %w", err)
return nil, fmt.Errorf("cannot extract nodeID from certificate: %w", err)
}

n := &Node{
Expand Down
4 changes: 2 additions & 2 deletions scripts/constants.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ current_branch=${current_branch_temp////-}
# caminogo and caminoethvm git tag and sha
git_commit=${CAMINO_NODE_COMMIT:-$(git rev-parse --short HEAD)}
git_tag=${CAMINO_NODE_TAG:-$(git describe --tags --abbrev=0 --always || echo unknown)}
caminoethvm_tag=${CAMINO_ETHVM_VERSION:-'v1.1.7-rc0'}
caminoethvm_commit=${CAMINOETHVM_COMMIT:-'383f4172f51a5dd6bc0dba1c1407fc4b1b0b06ad'}
caminoethvm_tag=${CAMINO_ETHVM_VERSION:-'v1.1.16-rc0'}
caminoethvm_commit=${CAMINOETHVM_COMMIT:-'d258907cfd8a448ccb111e9e0f232980f85bb0da'}

# Static compilation
static_ld_flags=''
Expand Down
2 changes: 1 addition & 1 deletion vms/platformvm/api/camino.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func buildCaminoGenesis(args *BuildGenesisArgs, reply *BuildGenesisReply) error
}

func makeValidator(
vdr *PermissionlessValidator,
vdr *GenesisPermissionlessValidator,
avaxAssetID ids.ID,
networkID uint32,
) (*txs.Tx, error) {
Expand Down
22 changes: 11 additions & 11 deletions vms/platformvm/api/camino_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func TestBuildCaminoGenesis(t *testing.T) {
Address: addrStr,
Amount: 10,
}},
Validators: []PermissionlessValidator{{
Staker: Staker{
Validators: []GenesisPermissionlessValidator{{
GenesisValidator: GenesisValidator{
StartTime: 0,
EndTime: 20,
NodeID: nodeID,
Expand Down Expand Up @@ -347,9 +347,9 @@ func TestBuildCaminoGenesis(t *testing.T) {
Amount: 10,
},
},
Validators: []PermissionlessValidator{
Validators: []GenesisPermissionlessValidator{
{
Staker: Staker{
GenesisValidator: GenesisValidator{
StartTime: 0,
EndTime: 20,
NodeID: nodeID,
Expand Down Expand Up @@ -407,7 +407,7 @@ func TestBuildCaminoGenesis(t *testing.T) {
Amount: 0,
},
},
Validators: []PermissionlessValidator{},
Validators: []GenesisPermissionlessValidator{},
Time: 5,
Encoding: formatting.Hex,
Camino: &Camino{
Expand Down Expand Up @@ -435,9 +435,9 @@ func TestBuildCaminoGenesis(t *testing.T) {
"Wrong Validator Number": {
args: BuildGenesisArgs{
UTXOs: []UTXO{},
Validators: []PermissionlessValidator{
Validators: []GenesisPermissionlessValidator{
{
Staker: Staker{
GenesisValidator: GenesisValidator{
StartTime: 0,
EndTime: 20,
NodeID: nodeID,
Expand Down Expand Up @@ -483,9 +483,9 @@ func TestBuildCaminoGenesis(t *testing.T) {
"Deposits and Staked Misalignment": {
args: BuildGenesisArgs{
UTXOs: []UTXO{},
Validators: []PermissionlessValidator{
Validators: []GenesisPermissionlessValidator{
{
Staker: Staker{
GenesisValidator: GenesisValidator{
StartTime: 0,
EndTime: 20,
NodeID: nodeID,
Expand Down Expand Up @@ -530,9 +530,9 @@ func TestBuildCaminoGenesis(t *testing.T) {
Amount: 0,
},
},
Validators: []PermissionlessValidator{
Validators: []GenesisPermissionlessValidator{
{
Staker: Staker{
GenesisValidator: GenesisValidator{
StartTime: 0,
EndTime: 20,
NodeID: nodeID,
Expand Down
18 changes: 9 additions & 9 deletions vms/platformvm/api/static_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,16 @@ type Chain struct {
// [Camino] are the camino specific genesis args.
// [Time] is the Platform Chain's time at network genesis.
type BuildGenesisArgs struct {
AvaxAssetID ids.ID `json:"avaxAssetID"`
NetworkID json.Uint32 `json:"networkID"`
UTXOs []UTXO `json:"utxos"`
AvaxAssetID ids.ID `json:"avaxAssetID"`
NetworkID json.Uint32 `json:"networkID"`
UTXOs []UTXO `json:"utxos"`
Validators []GenesisPermissionlessValidator `json:"validators"`
Chains []Chain `json:"chains"`
Camino *Camino `json:"camino"`
Time json.Uint64 `json:"time"`
InitialSupply json.Uint64 `json:"initialSupply"`
Message string `json:"message"`
Encoding formatting.Encoding `json:"encoding"`
Chains []Chain `json:"chains"`
Camino *Camino `json:"camino"`
Time json.Uint64 `json:"time"`
InitialSupply json.Uint64 `json:"initialSupply"`
Message string `json:"message"`
Encoding formatting.Encoding `json:"encoding"`
}

// BuildGenesisReply is the reply from BuildGenesis
Expand Down
46 changes: 0 additions & 46 deletions vms/platformvm/block/builder/camino_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,13 @@ import (

"github.com/ava-labs/avalanchego/database"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/engine/common"
"github.com/ava-labs/avalanchego/utils/timer"
"github.com/ava-labs/avalanchego/utils/timer/mockable"
"github.com/ava-labs/avalanchego/vms/platformvm/block"
blockexecutor "github.com/ava-labs/avalanchego/vms/platformvm/block/executor"
"github.com/ava-labs/avalanchego/vms/platformvm/state"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
txBuilder "github.com/ava-labs/avalanchego/vms/platformvm/txs/builder"
txexecutor "github.com/ava-labs/avalanchego/vms/platformvm/txs/executor"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/mempool"
)

// Overriding axax block builder methods with caminoBuilder methods
// must be done with consideration, that network uses reference to avax builder,
// not to camino builder. So it will actually call avax builder methods.

type caminoBuilder struct {
builder
caminoTxBuilder txBuilder.CaminoBuilder
}

func CaminoNew(
mempool mempool.Mempool,
txBuilder txBuilder.CaminoBuilder,
txExecutorBackend *txexecutor.Backend,
blkManager blockexecutor.Manager,
toEngine chan<- common.Message,
appSender common.AppSender,
) Builder {
builder := &caminoBuilder{
builder: builder{
Mempool: mempool,
txExecutorBackend: txExecutorBackend,
blkManager: blkManager,
toEngine: toEngine,
txBuilder: txBuilder,
},
caminoTxBuilder: txBuilder,
}

builder.timer = timer.NewTimer(builder.setNextBuildBlockTime)

builder.Network = NewCaminoNetwork(
txExecutorBackend.Ctx,
builder,
appSender,
builder.caminoTxBuilder,
)

go txExecutorBackend.Ctx.Log.RecoverAndPanic(builder.timer.Dispatch)
return builder
}

func caminoBuildBlock(
builder *builder,
parentID ids.ID,
Expand Down
8 changes: 4 additions & 4 deletions vms/platformvm/camino_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func newCaminoVM(t *testing.T, genesisConfig api.Camino, genesisUTXOs []api.UTXO
caminoPreFundedKeys[0].PublicKey().Address(),
)
require.NoError(err)
require.NoError(vm.Builder.AddUnverifiedTx(testSubnet1))
require.NoError(vm.Network.IssueTx(context.Background(), testSubnet1))
blk, err := vm.Builder.BuildBlock(context.Background())
require.NoError(err)
require.NoError(blk.Verify(context.Background()))
Expand Down Expand Up @@ -187,12 +187,12 @@ func newCaminoGenesisWithUTXOs(t *testing.T, caminoGenesisConfig api.Camino, gen
caminoGenesisConfig.ValidatorDeposits = make([][]api.UTXODeposit, len(caminoPreFundedKeys))
caminoGenesisConfig.ValidatorConsortiumMembers = make([]ids.ShortID, len(caminoPreFundedKeys))

genesisValidators := make([]api.PermissionlessValidator, len(caminoPreFundedKeys))
genesisValidators := make([]api.GenesisPermissionlessValidator, len(caminoPreFundedKeys))
for i, key := range caminoPreFundedKeys {
addr, err := address.FormatBech32(constants.UnitTestHRP, key.PublicKey().Address().Bytes())
require.NoError(err)
genesisValidators[i] = api.PermissionlessValidator{
Staker: api.Staker{
genesisValidators[i] = api.GenesisPermissionlessValidator{
GenesisValidator: api.GenesisValidator{
StartTime: json.Uint64(starttime.Unix()),
EndTime: json.Uint64(starttime.Add(10 * defaultMinStakingDuration).Unix()),
NodeID: caminoPreFundedNodeIDs[i],
Expand Down
30 changes: 8 additions & 22 deletions vms/platformvm/camino_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ type SetAddressStateArgs struct {
}

// AddAdressState issues an AddAdressStateTx
func (s *CaminoService) SetAddressState(_ *http.Request, args *SetAddressStateArgs, response *api.JSONTxID) error {
func (s *CaminoService) SetAddressState(req *http.Request, args *SetAddressStateArgs, response *api.JSONTxID) error {
s.vm.ctx.Log.Debug("Platform: SetAddressState called")

s.vm.ctx.Lock.Lock()
Expand Down Expand Up @@ -302,10 +302,7 @@ func (s *CaminoService) SetAddressState(_ *http.Request, args *SetAddressStateAr

response.TxID = tx.ID()

if err = s.vm.Builder.AddUnverifiedTx(tx); err != nil {
return err
}
return nil
return s.vm.Network.IssueTx(req.Context(), tx)
}

// GetAdressStates retrieves the state applied to an address (see setAddressState)
Expand Down Expand Up @@ -476,7 +473,7 @@ type RegisterNodeArgs struct {
}

// RegisterNode issues an RegisterNodeTx
func (s *CaminoService) RegisterNode(_ *http.Request, args *RegisterNodeArgs, reply *api.JSONTxID) error {
func (s *CaminoService) RegisterNode(req *http.Request, args *RegisterNodeArgs, reply *api.JSONTxID) error {
s.vm.ctx.Log.Debug("Platform: RegisterNode called")

s.vm.ctx.Lock.Lock()
Expand Down Expand Up @@ -512,10 +509,7 @@ func (s *CaminoService) RegisterNode(_ *http.Request, args *RegisterNodeArgs, re

reply.TxID = tx.ID()

if err = s.vm.Builder.AddUnverifiedTx(tx); err != nil {
return err
}
return nil
return s.vm.Network.IssueTx(req.Context(), tx)
}

type ClaimedAmount struct {
Expand All @@ -535,7 +529,7 @@ type ClaimArgs struct {
}

// Claim issues an ClaimTx
func (s *CaminoService) Claim(_ *http.Request, args *ClaimArgs, reply *api.JSONTxID) error {
func (s *CaminoService) Claim(req *http.Request, args *ClaimArgs, reply *api.JSONTxID) error {
s.vm.ctx.Log.Debug("Platform: Claim called")

s.vm.ctx.Lock.Lock()
Expand Down Expand Up @@ -591,11 +585,7 @@ func (s *CaminoService) Claim(_ *http.Request, args *ClaimArgs, reply *api.JSONT

reply.TxID = tx.ID()

if err := s.vm.Builder.AddUnverifiedTx(tx); err != nil {
return fmt.Errorf("couldn't create tx: %w", err)
}

return nil
return s.vm.Network.IssueTx(req.Context(), tx)
}

type TransferArgs struct {
Expand All @@ -607,7 +597,7 @@ type TransferArgs struct {
}

// Transfer issues an BaseTx
func (s *CaminoService) Transfer(_ *http.Request, args *TransferArgs, reply *api.JSONTxID) error {
func (s *CaminoService) Transfer(req *http.Request, args *TransferArgs, reply *api.JSONTxID) error {
s.vm.ctx.Log.Debug("Platform: Transfer called")

s.vm.ctx.Lock.Lock()
Expand Down Expand Up @@ -641,11 +631,7 @@ func (s *CaminoService) Transfer(_ *http.Request, args *TransferArgs, reply *api

reply.TxID = tx.ID()

if err := s.vm.Builder.AddUnverifiedTx(tx); err != nil {
return fmt.Errorf("couldn't create tx: %w", err)
}

return nil
return s.vm.Network.IssueTx(req.Context(), tx)
}

func (s *CaminoService) GetRegisteredShortIDLink(_ *http.Request, args *api.JSONAddress, response *api.JSONAddress) error {
Expand Down
Loading

0 comments on commit 300ac8b

Please sign in to comment.