Skip to content

Commit

Permalink
merged
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph committed Jan 2, 2024
2 parents 036c7f5 + 021f4f7 commit 991ee1c
Show file tree
Hide file tree
Showing 181 changed files with 2,279 additions and 1,906 deletions.
5 changes: 2 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
/message/ @gyuho
/network/ @danlaine @joshua-kim @StephenButtolph
/network/throttling/ @danlaine @dboehm-avalabs @StephenButtolph
/proto/ @gyuho @hexfusion
/proto/ @gyuho
/snow/ @danlaine @StephenButtolph
/snow/consensus/ @gyuho @StephenButtolph
/snow/engine/snowman/syncer/ @abi87
/snow/uptime/ @ceyonur
/utils/logging/ @ceyonur
/vms/platformvm/ @abi87 @danlaine @StephenButtolph
/vms/platformvm/ @abi87 @danlaine @dhrubabasu @StephenButtolph
/vms/proposervm/ @abi87 @StephenButtolph
/vms/rpcchainvm/ @hexfusion @StephenButtolph
/vms/registry/ @joshua-kim
/tests/ @abi87 @gyuho @marun
/x/ @danlaine @darioush @dboehm-avalabs
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "daily"
target-branch: "dev"
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To start developing on AvalancheGo, you'll need a few things installed.

## Features

- If you want to start a discussion about the development of a new feature or the modfiication of an existing one, start a thread under GitHub [discussions](https://github.com/ava-labs/avalanchego/discussions/categories/ideas).
- If you want to start a discussion about the development of a new feature or the modification of an existing one, start a thread under GitHub [discussions](https://github.com/ava-labs/avalanchego/discussions/categories/ideas).
- Post a thread about your idea and why it should be added to AvalancheGo.
- Don't start working on a pull request until you've received positive feedback from the maintainers.

Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Avalanche takes the security of the platform and of its users very seriously. We

## Reporting a Vulnerability

**Please do not file a public ticket** mentioning the vulnerability. To disclose a vulnerability submit it through our [Bug Bounty Program](https://hackenproof.com/avalanche).
**Please do not file a public ticket** mentioning the vulnerability. To disclose a vulnerability submit it through our [Bug Bounty Program](https://immunefi.com/bounty/avalanche/).

Vulnerabilities must be disclosed to us privately with reasonable time to respond, and avoid compromise of other users and accounts, or loss of funds that are not your own. We do not reward spam or social engineering vulnerabilities.

Do not test for or validate any security issues in the live Avalanche networks (Mainnet and Fuji testnet), confirm all exploits in a local private testnet.

Please refer to the [Bug Bounty Page](https://hackenproof.com/avalanche) for the most up-to-date program rules and scope.
Please refer to the [Bug Bounty Page](https://immunefi.com/bounty/avalanche/) for the most up-to-date program rules and scope.

## Supported Versions

Expand Down
8 changes: 1 addition & 7 deletions api/admin/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,23 @@ import (
type loadVMsTest struct {
admin *Admin
ctrl *gomock.Controller
mockLog *logging.MockLogger
mockVMManager *vms.MockManager
mockVMRegistry *registry.MockVMRegistry
}

func initLoadVMsTest(t *testing.T) *loadVMsTest {
ctrl := gomock.NewController(t)

mockLog := logging.NewMockLogger(ctrl)
mockVMRegistry := registry.NewMockVMRegistry(ctrl)
mockVMManager := vms.NewMockManager(ctrl)

return &loadVMsTest{
admin: &Admin{Config: Config{
Log: mockLog,
Log: logging.NoLog{},
VMRegistry: mockVMRegistry,
VMManager: mockVMManager,
}},
ctrl: ctrl,
mockLog: mockLog,
mockVMManager: mockVMManager,
mockVMRegistry: mockVMRegistry,
}
Expand Down Expand Up @@ -67,7 +64,6 @@ func TestLoadVMsSuccess(t *testing.T) {
id2: alias2[1:],
}

resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1)
resources.mockVMRegistry.EXPECT().ReloadWithReadLock(gomock.Any()).Times(1).Return(newVMs, failedVMs, nil)
resources.mockVMManager.EXPECT().Aliases(id1).Times(1).Return(alias1, nil)
resources.mockVMManager.EXPECT().Aliases(id2).Times(1).Return(alias2, nil)
Expand All @@ -84,7 +80,6 @@ func TestLoadVMsReloadFails(t *testing.T) {

resources := initLoadVMsTest(t)

resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1)
// Reload fails
resources.mockVMRegistry.EXPECT().ReloadWithReadLock(gomock.Any()).Times(1).Return(nil, nil, errTest)

Expand All @@ -108,7 +103,6 @@ func TestLoadVMsGetAliasesFails(t *testing.T) {
// every vm is at least aliased to itself.
alias1 := []string{id1.String(), "vm1-alias-1", "vm1-alias-2"}

resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1)
resources.mockVMRegistry.EXPECT().ReloadWithReadLock(gomock.Any()).Times(1).Return(newVMs, failedVMs, nil)
resources.mockVMManager.EXPECT().Aliases(id1).Times(1).Return(alias1, nil)
resources.mockVMManager.EXPECT().Aliases(id2).Times(1).Return(nil, errTest)
Expand Down
19 changes: 6 additions & 13 deletions api/info/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,20 @@ var errTest = errors.New("non-nil error")
type getVMsTest struct {
info *Info
ctrl *gomock.Controller
mockLog *logging.MockLogger
mockVMManager *vms.MockManager
}

func initGetVMsTest(t *testing.T) *getVMsTest {
ctrl := gomock.NewController(t)

service := Info{}
mockLog := logging.NewMockLogger(ctrl)
mockVMManager := vms.NewMockManager(ctrl)

service.log = mockLog
service.VMManager = mockVMManager

return &getVMsTest{
info: &service,
info: &Info{
Parameters: Parameters{
VMManager: mockVMManager,
},
log: logging.NoLog{},
},
ctrl: ctrl,
mockLog: mockLog,
mockVMManager: mockVMManager,
}
}
Expand All @@ -62,7 +58,6 @@ func TestGetVMsSuccess(t *testing.T) {
id2: alias2[1:],
}

resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1)
resources.mockVMManager.EXPECT().ListFactories().Times(1).Return(vmIDs, nil)
resources.mockVMManager.EXPECT().Aliases(id1).Times(1).Return(alias1, nil)
resources.mockVMManager.EXPECT().Aliases(id2).Times(1).Return(alias2, nil)
Expand All @@ -76,7 +71,6 @@ func TestGetVMsSuccess(t *testing.T) {
func TestGetVMsVMsListFactoriesFails(t *testing.T) {
resources := initGetVMsTest(t)

resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1)
resources.mockVMManager.EXPECT().ListFactories().Times(1).Return(nil, errTest)

reply := GetVMsReply{}
Expand All @@ -93,7 +87,6 @@ func TestGetVMsGetAliasesFails(t *testing.T) {
vmIDs := []ids.ID{id1, id2}
alias1 := []string{id1.String(), "vm1-alias-1", "vm1-alias-2"}

resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1)
resources.mockVMManager.EXPECT().ListFactories().Times(1).Return(vmIDs, nil)
resources.mockVMManager.EXPECT().Aliases(id1).Times(1).Return(alias1, nil)
resources.mockVMManager.EXPECT().Aliases(id2).Times(1).Return(nil, errTest)
Expand Down
10 changes: 5 additions & 5 deletions api/keystore/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import (
)

const (
CodecVersion = 0

maxPackerSize = 1 * units.GiB // max size, in bytes, of something being marshalled by Marshal()
maxSliceLength = linearcodec.DefaultMaxSliceLength

codecVersion = 0
)

var c codec.Manager
var Codec codec.Manager

func init() {
lc := linearcodec.NewCustomMaxLength(maxSliceLength)
c = codec.NewManager(maxPackerSize)
if err := c.RegisterCodec(codecVersion, lc); err != nil {
Codec = codec.NewManager(maxPackerSize)
if err := Codec.RegisterCodec(CodecVersion, lc); err != nil {
panic(err)
}
}
10 changes: 5 additions & 5 deletions api/keystore/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (ks *keystore) CreateUser(username, pw string) error {
return err
}

passwordBytes, err := c.Marshal(codecVersion, passwordHash)
passwordBytes, err := Codec.Marshal(CodecVersion, passwordHash)
if err != nil {
return err
}
Expand Down Expand Up @@ -288,14 +288,14 @@ func (ks *keystore) ImportUser(username, pw string, userBytes []byte) error {
}

userData := user{}
if _, err := c.Unmarshal(userBytes, &userData); err != nil {
if _, err := Codec.Unmarshal(userBytes, &userData); err != nil {
return err
}
if !userData.Hash.Check(pw) {
return fmt.Errorf("%w: user %q", errIncorrectPassword, username)
}

usrBytes, err := c.Marshal(codecVersion, &userData.Hash)
usrBytes, err := Codec.Marshal(CodecVersion, &userData.Hash)
if err != nil {
return err
}
Expand Down Expand Up @@ -355,7 +355,7 @@ func (ks *keystore) ExportUser(username, pw string) ([]byte, error) {
}

// Return the byte representation of the user
return c.Marshal(codecVersion, &userData)
return Codec.Marshal(CodecVersion, &userData)
}

func (ks *keystore) getPassword(username string) (*password.Hash, error) {
Expand All @@ -377,6 +377,6 @@ func (ks *keystore) getPassword(username string) (*password.Hash, error) {
}

passwordHash = &password.Hash{}
_, err = c.Unmarshal(userBytes, passwordHash)
_, err = Codec.Unmarshal(userBytes, passwordHash)
return passwordHash, err
}
3 changes: 0 additions & 3 deletions api/server/mock_server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions chains/atomic/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (
"github.com/ava-labs/avalanchego/codec/linearcodec"
)

const codecVersion = 0
const CodecVersion = 0

// codecManager is used to marshal and unmarshal dbElements and chain IDs.
var codecManager codec.Manager
// Codec is used to marshal and unmarshal dbElements and chain IDs.
var Codec codec.Manager

func init() {
linearCodec := linearcodec.NewDefault()
codecManager = codec.NewDefaultManager()
if err := codecManager.RegisterCodec(codecVersion, linearCodec); err != nil {
lc := linearcodec.NewDefault()
Codec = codec.NewDefaultManager()
if err := Codec.RegisterCodec(CodecVersion, lc); err != nil {
panic(err)
}
}
2 changes: 1 addition & 1 deletion chains/atomic/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func sharedID(id1, id2 ids.ID) ids.ID {
id1, id2 = id2, id1
}

combinedBytes, err := codecManager.Marshal(codecVersion, [2]ids.ID{id1, id2})
combinedBytes, err := Codec.Marshal(CodecVersion, [2]ids.ID{id1, id2})
if err != nil {
panic(err)
}
Expand Down
3 changes: 0 additions & 3 deletions chains/atomic/mock_shared_memory.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions chains/atomic/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (s *state) SetValue(e *Element) error {
Traits: e.Traits,
}

valueBytes, err := codecManager.Marshal(codecVersion, &dbElem)
valueBytes, err := Codec.Marshal(CodecVersion, &dbElem)
if err != nil {
return err
}
Expand Down Expand Up @@ -156,7 +156,7 @@ func (s *state) RemoveValue(key []byte) error {

// The value doesn't exist, so we should optimistically delete it
dbElem := dbElement{Present: false}
valueBytes, err := codecManager.Marshal(codecVersion, &dbElem)
valueBytes, err := Codec.Marshal(CodecVersion, &dbElem)
if err != nil {
return err
}
Expand Down Expand Up @@ -189,7 +189,7 @@ func (s *state) loadValue(key []byte) (*dbElement, error) {

// The key was in the database
value := &dbElement{}
_, err = codecManager.Unmarshal(valueBytes, value)
_, err = Codec.Unmarshal(valueBytes, value)
return value, err
}

Expand Down
3 changes: 0 additions & 3 deletions codec/mock_manager.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 991ee1c

Please sign in to comment.