Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
14ed270
Remove plugin handling from AMI generation (#2464)
StephenButtolph Jan 12, 2023
7a6793a
Remove copy of unused plugins directory (#2466)
StephenButtolph Jan 12, 2023
5b19d55
Remove unused rpm packaging scripts (#2465)
StephenButtolph Jan 12, 2023
166fe00
Add AVM `state.Chain` interface (#2411)
StephenButtolph Jan 12, 2023
92690ac
Simplify consensus context atomic values (#2473)
StephenButtolph Jan 13, 2023
bab4af5
Release lock before attempting to close a connection (#2481)
StephenButtolph Jan 17, 2023
32fbe5a
Remove engine dependency from chain registrants (#2482)
StephenButtolph Jan 17, 2023
67ad340
Add TCP proxy support (#2476)
StephenButtolph Jan 17, 2023
eca193c
Removed unused field from chain handler log (#2484)
StephenButtolph Jan 17, 2023
de547d3
Add engine type to consensus context (#2485)
StephenButtolph Jan 17, 2023
643e197
Initialize last accepted block to the genesis block, not the stop ver…
StephenButtolph Jan 17, 2023
303cd18
testing packer build
charlie-ava Jan 17, 2023
62e2d01
Set default answer and fixed typo
charlie-ava Jan 17, 2023
9e4533a
Removed evm from ansible roles
charlie-ava Jan 17, 2023
a8b290e
Removed proxy
charlie-ava Jan 18, 2023
a6dd0fe
Removed branch testing
charlie-ava Jan 18, 2023
e5afe54
testing packer
charlie-ava Jan 18, 2023
319cf6f
testing looked good, reseting to work on merge
charlie-ava Jan 18, 2023
00fdbb1
Fix `validators.Contains` documentation typo (#2507)
abi87 Jan 20, 2023
8918a43
Report percentages for uptimes in `platform.getCurrentValidators` (#2…
ceyonur Jan 20, 2023
b7b31a0
Optimize P-chain GetValidators when NodeIDs are provided (#2263)
abi87 Jan 23, 2023
4c368b1
Fix `RemoveSubnetValidatorTx` Weight Diff Calculation (#2510)
StephenButtolph Jan 23, 2023
cb7a3c1
Use generic btree implementation (#2522)
dhrubabasu Jan 24, 2023
84e1829
Convert caching to use generics (#1880)
Jan 24, 2023
56432c5
Cache stakers in platformvm get validators APIs (#2499)
abi87 Jan 24, 2023
455b894
Now allowing build on release candidates
charlie-ava Jan 24, 2023
9903972
Merge branch 'dev' into packer_validate
StephenButtolph Jan 24, 2023
ce7af4f
nit don't push updates for rcs
StephenButtolph Jan 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/packer/roles/public-ami/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ network: mainnet
db_dir: /data/avalanchego
log_dir: /var/log/avalanchego
config_dir: /etc/avalanchego
plugin_dir: /usr/local/lib/avalanchego/plugins
repo_url: https://github.com/ava-labs/avalanchego
repo_folder: /tmp/avalanchego
14 changes: 0 additions & 14 deletions .github/packer/roles/public-ami/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@
group: "{{ ava_group }}"
state: directory

- name: Create avalanche plugins directory
file:
path: "{{ plugin_dir }}"
owner: "{{ ava_user }}"
group: "{{ ava_group }}"
state: directory
recurse: yes

- name: Build avalanchego
command: ./scripts/build.sh
args:
Expand All @@ -85,12 +77,6 @@
args:
chdir: "{{ repo_folder }}"

- name: Copy evm binaries to the correct location
command: cp build/plugins/evm {{ plugin_dir }}
args:
chdir: "{{ repo_folder }}"


- name: Configure avalanche
template:
src: templates/conf.json.j2
Expand Down
1 change: 1 addition & 0 deletions .github/packer/ubuntu-focal-x86_64-public-ami.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"type": "ansible",
"playbook_file": ".github/packer/create_public_ami.yml",
"roles_path": ".github/packer/roles/",
"use_proxy": false,
"extra_arguments": ["-e", "component=public-ami build=packer os_release=focal tag={{user `tag`}}"]
},
{
Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/build-rpm-pkg.sh

This file was deleted.

4 changes: 0 additions & 4 deletions .github/workflows/build-tgz-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ OK=`cp ./build/avalanchego $AVALANCHE_ROOT`
if [[ $OK -ne 0 ]]; then
exit $OK;
fi
OK=`cp -r ./build/plugins $AVALANCHE_ROOT`
if [[ $OK -ne 0 ]]; then
exit $OK;
fi


echo "Build tgz package..."
Expand Down
55 changes: 29 additions & 26 deletions .github/workflows/update-ami.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
file = '.github/workflows/amichange.json'
packerfile = ".github/packer/ubuntu-focal-x86_64-public-ami.json"

update_marketplace = True
product_id = os.getenv('PRODUCT_ID')
role_arn = os.getenv('ROLE_ARN')
vtag = os.getenv('TAG')
Expand All @@ -18,14 +19,12 @@

for var in variables:
if var is None:
print("A Variable is not set correctly or this is not the right repo. Exiting.")
exit(0)
print("A Variable is not set correctly or this is not the right repo. Only validating packer.")
update_marketplace = False

if 'rc' in tag:
print("This is a release candidate. Nothing to do.")
exit(0)

client = boto3.client('marketplace-catalog',region_name='us-east-1')
print("This is a release candidate. Only validating packer.")
update_marketplace = False

def packer_build(packerfile):
p = packer.Packer(packerfile)
Expand All @@ -44,24 +43,28 @@ def parse_amichange(object):

amiid=packer_build(packerfile)

try:
response = client.start_change_set(
Catalog='AWSMarketplace',
ChangeSet=[
{
'ChangeType': 'AddDeliveryOptions',
'Entity': {
'Type': 'AmiProduct@1.0',
'Identifier': product_id
},
'Details': parse_amichange(file),
'ChangeName': 'Update'
},
],
ChangeSetName='AvalancheGo Update ' + tag,
ClientRequestToken=uid
)
print(response)
except client.exceptions.ResourceInUseException:
print("The product is currently blocked by Amazon. Please check the product site for more details")
if update_marketplace:

client = boto3.client('marketplace-catalog',region_name='us-east-1')

try:
response = client.start_change_set(
Catalog='AWSMarketplace',
ChangeSet=[
{
'ChangeType': 'AddDeliveryOptions',
'Entity': {
'Type': 'AmiProduct@1.0',
'Identifier': product_id
},
'Details': parse_amichange(file),
'ChangeName': 'Update'
},
],
ChangeSetName='AvalancheGo Update ' + tag,
ClientRequestToken=uid
)
print(response)
except client.exceptions.ResourceInUseException:
print("The product is currently blocked by Amazon. Please check the product site for more details")

22 changes: 0 additions & 22 deletions .github/workflows/yum/specfile/avalanchego.spec

This file was deleted.

6 changes: 3 additions & 3 deletions api/health/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ func TestPassingChecks(t *testing.T) {
func TestPassingThenFailingChecks(t *testing.T) {
require := require.New(t)

var shouldCheckErr utils.AtomicBool
var shouldCheckErr utils.Atomic[bool]
check := CheckerFunc(func(context.Context) (interface{}, error) {
if shouldCheckErr.GetValue() {
if shouldCheckErr.Get() {
return errUnhealthy.Error(), errUnhealthy
}
return "", nil
Expand Down Expand Up @@ -228,7 +228,7 @@ func TestPassingThenFailingChecks(t *testing.T) {
require.True(liveness)
}

shouldCheckErr.SetValue(true)
shouldCheckErr.Set(true)

awaitHealthy(h, false)
awaitLiveness(h, false)
Expand Down
8 changes: 4 additions & 4 deletions api/health/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ func (w *worker) RegisterCheck(name string, checker Checker) error {
}

func (w *worker) RegisterMonotonicCheck(name string, checker Checker) error {
var result utils.AtomicInterface
return w.RegisterCheck(name, CheckerFunc(func(ctx context.Context) (interface{}, error) {
details := result.GetValue()
var result utils.Atomic[any]
return w.RegisterCheck(name, CheckerFunc(func(ctx context.Context) (any, error) {
details := result.Get()
if details != nil {
return details, nil
}

details, err := checker.HealthCheck(ctx)
if err == nil {
result.SetValue(details)
result.Set(details)
}
return details, err
}))
Expand Down
9 changes: 5 additions & 4 deletions api/server/mock_server.go

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

23 changes: 7 additions & 16 deletions api/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,10 @@ type Server interface {
Dispatch() error
// DispatchTLS starts the API server with the provided TLS certificate
DispatchTLS(certBytes, keyBytes []byte) error
// RegisterChain registers the API endpoints associated with this chain. That is,
// add <route, handler> pairs to server so that API calls can be made to the VM.
// This method runs in a goroutine to avoid a deadlock in the event that the caller
// holds the engine's context lock. Namely, this could happen when the P-Chain is
// creating a new chain and holds the P-Chain's lock when this function is held,
// and at the same time the server's lock is held due to an API call and is trying
// to grab the P-Chain's lock.
RegisterChain(chainName string, engine common.Engine)
// RegisterChain registers the API endpoints associated with this chain.
// That is, add <route, handler> pairs to server so that API calls can be
// made to the VM.
RegisterChain(chainName string, ctx *snow.ConsensusContext, vm common.VM)
// Shutdown this server
Shutdown() error
}
Expand Down Expand Up @@ -217,19 +213,14 @@ func (s *server) DispatchTLS(certBytes, keyBytes []byte) error {
return s.srv.Serve(listener)
}

func (s *server) RegisterChain(chainName string, engine common.Engine) {
go s.registerChain(chainName, engine)
}

func (s *server) registerChain(chainName string, engine common.Engine) {
func (s *server) RegisterChain(chainName string, ctx *snow.ConsensusContext, vm common.VM) {
var (
handlers map[string]*common.HTTPHandler
err error
)

ctx := engine.Context()
ctx.Lock.Lock()
handlers, err = engine.GetVM().CreateHandlers(context.TODO())
handlers, err = vm.CreateHandlers(context.TODO())
ctx.Lock.Unlock()
if err != nil {
s.log.Error("failed to create handlers",
Expand Down Expand Up @@ -377,7 +368,7 @@ func lockMiddleware(
// not done state-syncing/bootstrapping, writes back an error.
func rejectMiddleware(handler http.Handler, ctx *snow.ConsensusContext) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // If chain isn't done bootstrapping, ignore API calls
if ctx.GetState() != snow.NormalOp {
if ctx.State.Get().State != snow.NormalOp {
w.WriteHeader(http.StatusServiceUnavailable)
// Doesn't matter if there's an error while writing. They'll get the StatusServiceUnavailable code.
_, _ = w.Write([]byte("API call rejected because chain is not done bootstrapping"))
Expand Down
23 changes: 10 additions & 13 deletions cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,34 @@

package cache

// Cacher acts as a best effort key value store. Keys must be comparable, as
// defined by https://golang.org/ref/spec#Comparison_operators.
type Cacher interface {
// Put inserts an element into the cache. If spaced is required, elements will
// Cacher acts as a best effort key value store.
type Cacher[K comparable, V any] interface {
// Put inserts an element into the cache. If space is required, elements will
// be evicted.
Put(key, value interface{})
Put(key K, value V)

// Get returns the entry in the cache with the key specified, if no value
// exists, false is returned.
Get(key interface{}) (interface{}, bool)
Get(key K) (V, bool)

// Evict removes the specified entry from the cache
Evict(key interface{})
Evict(key K)

// Flush removes all entries from the cache
Flush()
}

// Evictable allows the object to be notified when it is evicted
type Evictable interface {
// Key must return a comparable value as defined by
// https://golang.org/ref/spec#Comparison_operators.
Key() interface{}
type Evictable[K comparable] interface {
Key() K
Evict()
}

// Deduplicator acts as a best effort deduplication service
type Deduplicator interface {
type Deduplicator[K comparable, V Evictable[K]] interface {
// Deduplicate returns either the provided value, or a previously provided
// value with the same ID that hasn't yet been evicted
Deduplicate(Evictable) Evictable
Deduplicate(V) V

// Flush removes all entries from the cache
Flush()
Expand Down
Loading