From 2e10a6517fd347cf15a2fb37bd01a50c999baf7b Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Thu, 23 Apr 2020 17:55:05 -0400 Subject: [PATCH 1/9] add build successful msg --- scripts/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build.sh b/scripts/build.sh index 7000d3f..3e8243c 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -34,3 +34,4 @@ fi go build -o "$PREFIX/ava" "$GECKO_PATH/main/"*.go go build -o "$PREFIX/xputtest" "$GECKO_PATH/xputtest/"*.go go build -o "$PLUGIN_PREFIX/evm" "$CORETH_PATH/plugin/"*.go +echo "Build Successful" \ No newline at end of file From b1ea742cf22f117dd613f010041b6d523b5475ac Mon Sep 17 00:00:00 2001 From: Anil Dasari Date: Fri, 24 Apr 2020 13:01:42 -0700 Subject: [PATCH 2/9] minor fixes --- ids/id_test.go | 2 +- vms/platformvm/service.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ids/id_test.go b/ids/id_test.go index b541ed5..512952b 100644 --- a/ids/id_test.go +++ b/ids/id_test.go @@ -152,7 +152,7 @@ func TestIDHex(t *testing.T) { id := NewID([32]byte{'a', 'v', 'a', ' ', 'l', 'a', 'b', 's'}) expected := "617661206c61627300000000000000000000000000000000000000000000000000" actual := id.Hex() - if actual != actual { + if actual != expected { t.Fatalf("got %s, expected %s", actual, expected) } } diff --git a/vms/platformvm/service.go b/vms/platformvm/service.go index b911c2a..86093b0 100644 --- a/vms/platformvm/service.go +++ b/vms/platformvm/service.go @@ -1227,6 +1227,10 @@ func (service *Service) chainExists(blockID ids.ID, chainID ids.ID) (bool, error db := block.onAccept() chains, err := service.vm.getChains(db) + if err != nil { + return false, err + } + for _, chain := range chains { if chain.ID().Equals(chainID) { return true, nil From 628856992fda7cd30a9b0d3bd195adda202818f0 Mon Sep 17 00:00:00 2001 From: Anil Dasari Date: Fri, 24 Apr 2020 13:23:07 -0700 Subject: [PATCH 3/9] added warn log incase of addroute failure --- vms/manager.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vms/manager.go b/vms/manager.go index 9f8cf3b..4449c27 100644 --- a/vms/manager.go +++ b/vms/manager.go @@ -131,6 +131,8 @@ func (m *manager) addStaticAPIEndpoints(vmID ids.ID) { // register the static endpoints for extension, service := range staticVM.CreateStaticHandlers() { m.log.Verbo("adding static API endpoint: %s", defaultEndpoint+extension) - m.apiServer.AddRoute(service, lock, defaultEndpoint, extension, m.log) + if err := m.apiServer.AddRoute(service, lock, defaultEndpoint, extension, m.log); err != nil { + m.log.Warn("failed to add static API endpoint %s: %v", fmt.Sprintf("%s%s", defaultEndpoint, extension), err) + } } } From 737087f0ca84b30d67fd222623161b43fa1f293a Mon Sep 17 00:00:00 2001 From: Anil Dasari Date: Fri, 24 Apr 2020 13:31:12 -0700 Subject: [PATCH 4/9] error check and go fmt --- vms/avm/vm.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vms/avm/vm.go b/vms/avm/vm.go index c8b33f1..af87871 100644 --- a/vms/avm/vm.go +++ b/vms/avm/vm.go @@ -91,8 +91,10 @@ func (cr *codecRegistry) RegisterType(val interface{}) error { cr.typeToFxIndex[valType] = cr.index return cr.codec.RegisterType(val) } -func (cr *codecRegistry) Marshal(val interface{}) ([]byte, error) { return cr.codec.Marshal(val) } -func (cr *codecRegistry) Unmarshal(b []byte, val interface{}) error { return cr.codec.Unmarshal(b, val) } +func (cr *codecRegistry) Marshal(val interface{}) ([]byte, error) { return cr.codec.Marshal(val) } +func (cr *codecRegistry) Unmarshal(b []byte, val interface{}) error { + return cr.codec.Unmarshal(b, val) +} /* ****************************************************************************** @@ -456,7 +458,10 @@ func (vm *VM) parseTx(b []byte) (*UniqueTx, error) { if err := vm.state.SetTx(tx.ID(), tx.Tx); err != nil { return nil, err } - tx.setStatus(choices.Processing) + + if err := tx.setStatus(choices.Processing); err != nil { + return nil, err + } } return tx, nil From 88228ac1d61b7508cefe1da162de1d36c85b6a5b Mon Sep 17 00:00:00 2001 From: Anil Dasari Date: Fri, 24 Apr 2020 13:42:36 -0700 Subject: [PATCH 5/9] error check --- vms/avm/vm.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vms/avm/vm.go b/vms/avm/vm.go index af87871..a46244d 100644 --- a/vms/avm/vm.go +++ b/vms/avm/vm.go @@ -389,7 +389,9 @@ func (vm *VM) initAliases(genesisBytes []byte) error { txID := tx.ID() - vm.Alias(txID, genesisTx.Alias) + if err = vm.Alias(txID, genesisTx.Alias); err != nil { + return err + } } return nil From 5440369118b764892bdc9c44617b31c60f74087a Mon Sep 17 00:00:00 2001 From: Anil Dasari Date: Fri, 24 Apr 2020 14:47:05 -0700 Subject: [PATCH 6/9] static analyis fixes --- vms/components/codec/codec.go | 5 +---- vms/components/core/snowman_vm.go | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/vms/components/codec/codec.go b/vms/components/codec/codec.go index 8005f34..72192cb 100644 --- a/vms/components/codec/codec.go +++ b/vms/components/codec/codec.go @@ -341,8 +341,5 @@ func (c codec) unmarshal(p *wrappers.Packer, field reflect.Value) error { // Returns true iff [field] should be serialized func shouldSerialize(field reflect.StructField) bool { - if field.Tag.Get("serialize") == "true" { - return true - } - return false + return field.Tag.Get("serialize") == "true" } diff --git a/vms/components/core/snowman_vm.go b/vms/components/core/snowman_vm.go index f710edd..bc849af 100644 --- a/vms/components/core/snowman_vm.go +++ b/vms/components/core/snowman_vm.go @@ -95,10 +95,7 @@ func (svm *SnowmanVM) Shutdown() { // DBInitialized returns true iff [svm]'s database has values in it already func (svm *SnowmanVM) DBInitialized() bool { status := svm.State.GetStatus(svm.DB, dbInitializedID) - if status == choices.Accepted { - return true - } - return false + return status == choices.Accepted } // SetDBInitialized marks the database as initialized From 8b76cf601ef43f9c90c41997dfc123aa154bf59c Mon Sep 17 00:00:00 2001 From: Anil Dasari Date: Fri, 24 Apr 2020 14:54:24 -0700 Subject: [PATCH 7/9] replaced loop --- snow/engine/avalanche/bootstrapper.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/snow/engine/avalanche/bootstrapper.go b/snow/engine/avalanche/bootstrapper.go index 7bacd46..0fd86a3 100644 --- a/snow/engine/avalanche/bootstrapper.go +++ b/snow/engine/avalanche/bootstrapper.go @@ -177,9 +177,7 @@ func (b *bootstrapper) storeVertex(vtx avalanche.Vertex) { } } - for _, parent := range vtx.Parents() { - vts = append(vts, parent) - } + vts = append(vts, vtx.Parents()...) case choices.Accepted: b.BootstrapConfig.Context.Log.Verbo("Bootstrapping confirmed %s", vtxID) case choices.Rejected: From f2c4c8195d5ae23a3e0fa9d4ad650ffa61feed01 Mon Sep 17 00:00:00 2001 From: Anil Dasari Date: Fri, 24 Apr 2020 21:15:31 -0700 Subject: [PATCH 8/9] testcase fix --- ids/id_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ids/id_test.go b/ids/id_test.go index 512952b..c43dc3a 100644 --- a/ids/id_test.go +++ b/ids/id_test.go @@ -150,7 +150,7 @@ func TestIDUnmarshalJSON(t *testing.T) { func TestIDHex(t *testing.T) { id := NewID([32]byte{'a', 'v', 'a', ' ', 'l', 'a', 'b', 's'}) - expected := "617661206c61627300000000000000000000000000000000000000000000000000" + expected := "617661206c616273000000000000000000000000000000000000000000000000" actual := id.Hex() if actual != expected { t.Fatalf("got %s, expected %s", actual, expected) From 592fb896fffcd4319abf241e0522c8e9979d60e2 Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Sun, 26 Apr 2020 14:28:36 -0400 Subject: [PATCH 9/9] check that binaries actually exist --- scripts/build.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index 3e8243c..46147a9 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -34,4 +34,8 @@ fi go build -o "$PREFIX/ava" "$GECKO_PATH/main/"*.go go build -o "$PREFIX/xputtest" "$GECKO_PATH/xputtest/"*.go go build -o "$PLUGIN_PREFIX/evm" "$CORETH_PATH/plugin/"*.go -echo "Build Successful" \ No newline at end of file +if [[ -f "$PREFIX/ava" && -f "$PREFIX/xputtest" && -f "$PLUGIN_PREFIX/evm" ]]; then + echo "Build Successful" +else + echo "Build failure" +fi \ No newline at end of file