Merge branch 'master' into platformvm-proposal-accept

This commit is contained in:
Stephen Buttolph 2020-04-28 19:35:13 -04:00 committed by GitHub
commit 34af9fb7f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 28 additions and 18 deletions

View File

@ -150,9 +150,9 @@ 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 != actual {
if actual != expected {
t.Fatalf("got %s, expected %s", actual, expected)
}
}

View File

@ -34,3 +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
if [[ -f "$PREFIX/ava" && -f "$PREFIX/xputtest" && -f "$PLUGIN_PREFIX/evm" ]]; then
echo "Build Successful"
else
echo "Build failure"
fi

View File

@ -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:

View File

@ -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)
}
/*
******************************************************************************
@ -387,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
@ -456,7 +460,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

View File

@ -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"
}

View File

@ -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

View File

@ -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)
}
}
}

View File

@ -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