From be6be7ae1c1e06fc29d352770836f7f0065cc63d Mon Sep 17 00:00:00 2001 From: StephenButtolph Date: Thu, 18 Jun 2020 01:45:58 -0400 Subject: [PATCH] reverted breaking changes --- genesis/genesis_test.go | 4 +- genesis/network_id.go | 2 +- main/params.go | 2 +- network/commands.go | 10 +- network/peer.go | 20 ++-- node/node.go | 2 +- .../add_default_subnet_delegator_tx.go | 2 +- .../add_default_subnet_delegator_tx_test.go | 94 +++++++++---------- 8 files changed, 69 insertions(+), 67 deletions(-) diff --git a/genesis/genesis_test.go b/genesis/genesis_test.go index c80767d..292fdee 100644 --- a/genesis/genesis_test.go +++ b/genesis/genesis_test.go @@ -26,8 +26,8 @@ func TestNetworkName(t *testing.T) { if name := NetworkName(EverestID); name != EverestName { t.Fatalf("NetworkID was incorrectly named. Result: %s ; Expected: %s", name, EverestName) } - if name := NetworkName(TestnetID); name != EverestName { - t.Fatalf("NetworkID was incorrectly named. Result: %s ; Expected: %s", name, EverestName) + if name := NetworkName(DenaliID); name != DenaliName { + t.Fatalf("NetworkID was incorrectly named. Result: %s ; Expected: %s", name, DenaliName) } if name := NetworkName(4294967295); name != "network-4294967295" { t.Fatalf("NetworkID was incorrectly named. Result: %s ; Expected: %s", name, "network-4294967295") diff --git a/genesis/network_id.go b/genesis/network_id.go index f318a36..880583e 100644 --- a/genesis/network_id.go +++ b/genesis/network_id.go @@ -18,7 +18,7 @@ var ( DenaliID uint32 = 3 EverestID uint32 = 4 - TestnetID uint32 = 4 + TestnetID uint32 = 3 LocalID uint32 = 12345 MainnetName = "mainnet" diff --git a/main/params.go b/main/params.go index 468a599..1e526b3 100644 --- a/main/params.go +++ b/main/params.go @@ -30,7 +30,7 @@ import ( ) const ( - dbVersion = "v0.6.0" + dbVersion = "v0.5.0" ) // Results of parsing the CLI diff --git a/network/commands.go b/network/commands.go index a5a9006..06fc31b 100644 --- a/network/commands.go +++ b/network/commands.go @@ -170,21 +170,23 @@ const ( Version GetPeerList PeerList - Ping - Pong // Bootstrapping: GetAcceptedFrontier AcceptedFrontier GetAccepted Accepted - GetAncestors - MultiPut // Consensus: Get Put PushQuery PullQuery Chits + + // TODO: Reorder these messages when we transition to everest + GetAncestors + MultiPut + Ping + Pong ) // Defines the messages that can be sent/received with this network diff --git a/network/peer.go b/network/peer.go index 9fd801f..409d7f6 100644 --- a/network/peer.go +++ b/network/peer.go @@ -64,7 +64,7 @@ func (p *peer) Start() { // Initially send the version to the peer go p.Version() go p.requestVersion() - go p.sendPings() + // go p.sendPings() } func (p *peer) sendPings() { @@ -107,10 +107,10 @@ func (p *peer) requestVersion() { func (p *peer) ReadMessages() { defer p.Close() - if err := p.conn.SetReadDeadline(p.net.clock.Time().Add(p.net.pingPongTimeout)); err != nil { - p.net.log.Verbo("error on setting the connection read timeout %s", err) - return - } + // if err := p.conn.SetReadDeadline(p.net.clock.Time().Add(p.net.pingPongTimeout)); err != nil { + // p.net.log.Verbo("error on setting the connection read timeout %s", err) + // return + // } pendingBuffer := wrappers.Packer{} readBuffer := make([]byte, 1<<10) @@ -246,11 +246,11 @@ func (p *peer) handle(msg Msg) { currentTime := p.net.clock.Time() atomic.StoreInt64(&p.lastReceived, currentTime.Unix()) - if err := p.conn.SetReadDeadline(currentTime.Add(p.net.pingPongTimeout)); err != nil { - p.net.log.Verbo("error on setting the connection read timeout %s, closing the connection", err) - p.Close() - return - } + // if err := p.conn.SetReadDeadline(currentTime.Add(p.net.pingPongTimeout)); err != nil { + // p.net.log.Verbo("error on setting the connection read timeout %s, closing the connection", err) + // p.Close() + // return + // } op := msg.Op() msgMetrics := p.net.message(op) diff --git a/node/node.go b/node/node.go index eae8cfd..752c78d 100644 --- a/node/node.go +++ b/node/node.go @@ -57,7 +57,7 @@ var ( genesisHashKey = []byte("genesisID") // Version is the version of this code - Version = version.NewDefaultVersion("avalanche", 0, 6, 0) + Version = version.NewDefaultVersion("avalanche", 0, 5, 5) versionParser = version.NewDefaultParser() ) diff --git a/vms/platformvm/add_default_subnet_delegator_tx.go b/vms/platformvm/add_default_subnet_delegator_tx.go index 9881652..3012d84 100644 --- a/vms/platformvm/add_default_subnet_delegator_tx.go +++ b/vms/platformvm/add_default_subnet_delegator_tx.go @@ -128,7 +128,7 @@ func (tx *addDefaultSubnetDelegatorTx) SemanticVerify(db database.Database) (*ve // The account if this block's proposal is committed and the validator is // added to the pending validator set. (Increase the account's nonce; // decrease its balance.) - newAccount, err := account.Remove(tx.Wght, tx.Nonce) // Remove also removes the fee + newAccount, err := account.Remove(0, tx.Nonce) // Remove also removes the fee if err != nil { return nil, nil, nil, nil, permError{err} } diff --git a/vms/platformvm/add_default_subnet_delegator_tx_test.go b/vms/platformvm/add_default_subnet_delegator_tx_test.go index 9380001..4b6fe80 100644 --- a/vms/platformvm/add_default_subnet_delegator_tx_test.go +++ b/vms/platformvm/add_default_subnet_delegator_tx_test.go @@ -335,9 +335,9 @@ func TestAddDefaultSubnetDelegatorTxSemanticVerify(t *testing.T) { } tx, err = vm.newAddDefaultSubnetDelegatorTx( - defaultNonce+1, // nonce - defaultStakeAmount, // weight - uint64(newTimestamp.Unix()), // start time + defaultNonce+1, // nonce + defaultStakeAmount, // weight + uint64(newTimestamp.Unix()), // start time uint64(newTimestamp.Add(MinimumStakingDuration).Unix()), // end time defaultKey.PublicKey().Address(), // node ID defaultKey.PublicKey().Address(), // destination @@ -387,51 +387,51 @@ func TestAddDefaultSubnetDelegatorTxSemanticVerify(t *testing.T) { } txFee = txFeeSaved // Reset tx fee - // Case 8: fail verification for spending more funds than it has - tx, err = vm.newAddDefaultSubnetDelegatorTx( - defaultNonce+1, - defaultBalance*2, // weight - uint64(defaultValidateStartTime.Unix()), // start time - uint64(defaultValidateEndTime.Unix()), // end time - defaultKey.PublicKey().Address(), // node ID - defaultKey.PublicKey().Address(), // destination - testNetworkID, // network ID - defaultKey, // tx fee payer - ) - if err != nil { - t.Fatal(err) - } - _, _, _, _, err = tx.SemanticVerify(vm.DB) - if err == nil { - t.Fatal("should have failed verification because payer account spent twice the account's balance") - } + // // Case 8: fail verification for spending more funds than it has + // tx, err = vm.newAddDefaultSubnetDelegatorTx( + // defaultNonce+1, + // defaultBalance*2, // weight + // uint64(defaultValidateStartTime.Unix()), // start time + // uint64(defaultValidateEndTime.Unix()), // end time + // defaultKey.PublicKey().Address(), // node ID + // defaultKey.PublicKey().Address(), // destination + // testNetworkID, // network ID + // defaultKey, // tx fee payer + // ) + // if err != nil { + // t.Fatal(err) + // } + // _, _, _, _, err = tx.SemanticVerify(vm.DB) + // if err == nil { + // t.Fatal("should have failed verification because payer account spent twice the account's balance") + // } - // Case 9: Confirm balance is correct - tx, err = vm.newAddDefaultSubnetDelegatorTx( - defaultNonce+1, - defaultStakeAmount, // weight - uint64(defaultValidateStartTime.Unix()), // start time - uint64(defaultValidateEndTime.Unix()), // end time - defaultKey.PublicKey().Address(), // node ID - defaultKey.PublicKey().Address(), // destination - testNetworkID, // network ID - defaultKey, // tx fee payer - ) - if err != nil { - t.Fatal(err) - } + // // Case 9: Confirm balance is correct + // tx, err = vm.newAddDefaultSubnetDelegatorTx( + // defaultNonce+1, + // defaultStakeAmount, // weight + // uint64(defaultValidateStartTime.Unix()), // start time + // uint64(defaultValidateEndTime.Unix()), // end time + // defaultKey.PublicKey().Address(), // node ID + // defaultKey.PublicKey().Address(), // destination + // testNetworkID, // network ID + // defaultKey, // tx fee payer + // ) + // if err != nil { + // t.Fatal(err) + // } - onCommitDB, _, _, _, err := tx.SemanticVerify(vm.DB) - if err != nil { - t.Fatal(err) - } - account, err := tx.vm.getAccount(onCommitDB, defaultKey.PublicKey().Address()) - if err != nil { - t.Fatal(err) - } - balance := account.Balance + // onCommitDB, _, _, _, err := tx.SemanticVerify(vm.DB) + // if err != nil { + // t.Fatal(err) + // } + // account, err := tx.vm.getAccount(onCommitDB, defaultKey.PublicKey().Address()) + // if err != nil { + // t.Fatal(err) + // } + // balance := account.Balance - if balance != defaultBalance-(defaultStakeAmount+txFee) { - t.Fatalf("balance was not updated correctly after subnet delegator tx") - } + // if balance != defaultBalance-(defaultStakeAmount+txFee) { + // t.Fatalf("balance was not updated correctly after subnet delegator tx") + // } }