reverted breaking changes

This commit is contained in:
StephenButtolph 2020-06-18 01:45:58 -04:00
parent 45b9a230b6
commit be6be7ae1c
8 changed files with 69 additions and 67 deletions

View File

@ -26,8 +26,8 @@ func TestNetworkName(t *testing.T) {
if name := NetworkName(EverestID); name != EverestName { if name := NetworkName(EverestID); name != EverestName {
t.Fatalf("NetworkID was incorrectly named. Result: %s ; Expected: %s", name, EverestName) t.Fatalf("NetworkID was incorrectly named. Result: %s ; Expected: %s", name, EverestName)
} }
if name := NetworkName(TestnetID); name != EverestName { if name := NetworkName(DenaliID); name != DenaliName {
t.Fatalf("NetworkID was incorrectly named. Result: %s ; Expected: %s", name, EverestName) t.Fatalf("NetworkID was incorrectly named. Result: %s ; Expected: %s", name, DenaliName)
} }
if name := NetworkName(4294967295); name != "network-4294967295" { if name := NetworkName(4294967295); name != "network-4294967295" {
t.Fatalf("NetworkID was incorrectly named. Result: %s ; Expected: %s", name, "network-4294967295") t.Fatalf("NetworkID was incorrectly named. Result: %s ; Expected: %s", name, "network-4294967295")

View File

@ -18,7 +18,7 @@ var (
DenaliID uint32 = 3 DenaliID uint32 = 3
EverestID uint32 = 4 EverestID uint32 = 4
TestnetID uint32 = 4 TestnetID uint32 = 3
LocalID uint32 = 12345 LocalID uint32 = 12345
MainnetName = "mainnet" MainnetName = "mainnet"

View File

@ -30,7 +30,7 @@ import (
) )
const ( const (
dbVersion = "v0.6.0" dbVersion = "v0.5.0"
) )
// Results of parsing the CLI // Results of parsing the CLI

View File

@ -170,21 +170,23 @@ const (
Version Version
GetPeerList GetPeerList
PeerList PeerList
Ping
Pong
// Bootstrapping: // Bootstrapping:
GetAcceptedFrontier GetAcceptedFrontier
AcceptedFrontier AcceptedFrontier
GetAccepted GetAccepted
Accepted Accepted
GetAncestors
MultiPut
// Consensus: // Consensus:
Get Get
Put Put
PushQuery PushQuery
PullQuery PullQuery
Chits 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 // Defines the messages that can be sent/received with this network

View File

@ -64,7 +64,7 @@ func (p *peer) Start() {
// Initially send the version to the peer // Initially send the version to the peer
go p.Version() go p.Version()
go p.requestVersion() go p.requestVersion()
go p.sendPings() // go p.sendPings()
} }
func (p *peer) sendPings() { func (p *peer) sendPings() {
@ -107,10 +107,10 @@ func (p *peer) requestVersion() {
func (p *peer) ReadMessages() { func (p *peer) ReadMessages() {
defer p.Close() defer p.Close()
if err := p.conn.SetReadDeadline(p.net.clock.Time().Add(p.net.pingPongTimeout)); err != nil { // 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) // p.net.log.Verbo("error on setting the connection read timeout %s", err)
return // return
} // }
pendingBuffer := wrappers.Packer{} pendingBuffer := wrappers.Packer{}
readBuffer := make([]byte, 1<<10) readBuffer := make([]byte, 1<<10)
@ -246,11 +246,11 @@ func (p *peer) handle(msg Msg) {
currentTime := p.net.clock.Time() currentTime := p.net.clock.Time()
atomic.StoreInt64(&p.lastReceived, currentTime.Unix()) atomic.StoreInt64(&p.lastReceived, currentTime.Unix())
if err := p.conn.SetReadDeadline(currentTime.Add(p.net.pingPongTimeout)); err != nil { // 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.net.log.Verbo("error on setting the connection read timeout %s, closing the connection", err)
p.Close() // p.Close()
return // return
} // }
op := msg.Op() op := msg.Op()
msgMetrics := p.net.message(op) msgMetrics := p.net.message(op)

View File

@ -57,7 +57,7 @@ var (
genesisHashKey = []byte("genesisID") genesisHashKey = []byte("genesisID")
// Version is the version of this code // Version is the version of this code
Version = version.NewDefaultVersion("avalanche", 0, 6, 0) Version = version.NewDefaultVersion("avalanche", 0, 5, 5)
versionParser = version.NewDefaultParser() versionParser = version.NewDefaultParser()
) )

View File

@ -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 // The account if this block's proposal is committed and the validator is
// added to the pending validator set. (Increase the account's nonce; // added to the pending validator set. (Increase the account's nonce;
// decrease its balance.) // 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 { if err != nil {
return nil, nil, nil, nil, permError{err} return nil, nil, nil, nil, permError{err}
} }

View File

@ -335,9 +335,9 @@ func TestAddDefaultSubnetDelegatorTxSemanticVerify(t *testing.T) {
} }
tx, err = vm.newAddDefaultSubnetDelegatorTx( tx, err = vm.newAddDefaultSubnetDelegatorTx(
defaultNonce+1, // nonce defaultNonce+1, // nonce
defaultStakeAmount, // weight defaultStakeAmount, // weight
uint64(newTimestamp.Unix()), // start time uint64(newTimestamp.Unix()), // start time
uint64(newTimestamp.Add(MinimumStakingDuration).Unix()), // end time uint64(newTimestamp.Add(MinimumStakingDuration).Unix()), // end time
defaultKey.PublicKey().Address(), // node ID defaultKey.PublicKey().Address(), // node ID
defaultKey.PublicKey().Address(), // destination defaultKey.PublicKey().Address(), // destination
@ -387,51 +387,51 @@ func TestAddDefaultSubnetDelegatorTxSemanticVerify(t *testing.T) {
} }
txFee = txFeeSaved // Reset tx fee txFee = txFeeSaved // Reset tx fee
// Case 8: fail verification for spending more funds than it has // // Case 8: fail verification for spending more funds than it has
tx, err = vm.newAddDefaultSubnetDelegatorTx( // tx, err = vm.newAddDefaultSubnetDelegatorTx(
defaultNonce+1, // defaultNonce+1,
defaultBalance*2, // weight // defaultBalance*2, // weight
uint64(defaultValidateStartTime.Unix()), // start time // uint64(defaultValidateStartTime.Unix()), // start time
uint64(defaultValidateEndTime.Unix()), // end time // uint64(defaultValidateEndTime.Unix()), // end time
defaultKey.PublicKey().Address(), // node ID // defaultKey.PublicKey().Address(), // node ID
defaultKey.PublicKey().Address(), // destination // defaultKey.PublicKey().Address(), // destination
testNetworkID, // network ID // testNetworkID, // network ID
defaultKey, // tx fee payer // defaultKey, // tx fee payer
) // )
if err != nil { // if err != nil {
t.Fatal(err) // t.Fatal(err)
} // }
_, _, _, _, err = tx.SemanticVerify(vm.DB) // _, _, _, _, err = tx.SemanticVerify(vm.DB)
if err == nil { // if err == nil {
t.Fatal("should have failed verification because payer account spent twice the account's balance") // t.Fatal("should have failed verification because payer account spent twice the account's balance")
} // }
// Case 9: Confirm balance is correct // // Case 9: Confirm balance is correct
tx, err = vm.newAddDefaultSubnetDelegatorTx( // tx, err = vm.newAddDefaultSubnetDelegatorTx(
defaultNonce+1, // defaultNonce+1,
defaultStakeAmount, // weight // defaultStakeAmount, // weight
uint64(defaultValidateStartTime.Unix()), // start time // uint64(defaultValidateStartTime.Unix()), // start time
uint64(defaultValidateEndTime.Unix()), // end time // uint64(defaultValidateEndTime.Unix()), // end time
defaultKey.PublicKey().Address(), // node ID // defaultKey.PublicKey().Address(), // node ID
defaultKey.PublicKey().Address(), // destination // defaultKey.PublicKey().Address(), // destination
testNetworkID, // network ID // testNetworkID, // network ID
defaultKey, // tx fee payer // defaultKey, // tx fee payer
) // )
if err != nil { // if err != nil {
t.Fatal(err) // t.Fatal(err)
} // }
onCommitDB, _, _, _, err := tx.SemanticVerify(vm.DB) // onCommitDB, _, _, _, err := tx.SemanticVerify(vm.DB)
if err != nil { // if err != nil {
t.Fatal(err) // t.Fatal(err)
} // }
account, err := tx.vm.getAccount(onCommitDB, defaultKey.PublicKey().Address()) // account, err := tx.vm.getAccount(onCommitDB, defaultKey.PublicKey().Address())
if err != nil { // if err != nil {
t.Fatal(err) // t.Fatal(err)
} // }
balance := account.Balance // balance := account.Balance
if balance != defaultBalance-(defaultStakeAmount+txFee) { // if balance != defaultBalance-(defaultStakeAmount+txFee) {
t.Fatalf("balance was not updated correctly after subnet delegator tx") // t.Fatalf("balance was not updated correctly after subnet delegator tx")
} // }
} }