Skip to content

Commit 83bccc5

Browse files
jannottitsachihermantolikzinovyevalgojackfionnachan
authored
merge before audit (#3431)
* Three new globals for to help contract-to-contract usability * detritis * Check error * doc comments * Impose limits on the entire "tree" of inner calls. This also increases the realism of testing of multiple app calls in a group by creating the EvalParams with the real constructor, thus getting the pooling stuff tested here without playing games manipulating the ep after construction. * Move appID tracking into EvalContext, out of LedgerForLogic This change increases the seperation between AVM execution and the ledger being used to lookup resources. Previously, the ledger kept track of the appID being executed, to offer a narrower interface to those resources. But now, with app-to-app calls, the appID being executed must change, and the AVM needs to maintain the current appID. * Stupid linter * Fix unit tests error messages * Allow access to resources created in the same transaction group The method will be reworked, but the tests are correct and want to get them visible to team. * Access to apps created in group Also adds some tests that are currently skipped for testing - access to addresses of newly created apps - use of gaid in inner transactions Both require some work to implement the thing being tested. * Remove tracked created mechanism in favor of examining applydata. * Allow v6 AVM code to use in-group created asas, apps (& their accts) One exception - apps can not mutate (put or del) keys from the app accounts, because EvalDelta cannot encode such changes. * lint docs * typo * The review dog needs obedience training. * Use one EvalParams for logic evals, another for apps in dry run We used to use one ep per transaction, shared between sig and and app. But the new model of ep usage is to keep using one while evaluating an entire group. The app ep is now built logic.NewAppEvalParams which, hopefully, will prevent some bugs when we change something in the EvalParams and don't reflect it in what was a "raw" EvalParams construction in debugger and dry run. * Use logic.NewAppEvalParams to decrease copying and bugs in debugger * Simplify use of NewEvalParams. No more nil return when no apps. This way, NewEvalParams can be used for all creations of EvalParams, whether they are intended for logicsig or app use, greatly simplifying the way we make them for use by dry run or debugger (where they serve double duty). * Remove explicit PastSideEffects handling in tealdbg * Always create EvalParams to evaluate a transaction group. We used to have an optimization to avoid creating EvalParams unless there was an app call in the transaction group. But the interface to allow transaction processing to communicate changes into the EvalParams is complicated by that (we must only do it if there is one!) This also allows us to use the same construction function for eps created for app and logic evaluation, simplifying dry-run and debugger. The optimization is less needed now anyway: 1) The ep is now shared for the whole group, so it's only one. 2) The ep is smaller now, as we only store nil pointers instead of larger scratch space objects for non-app calls. * Correct mistaken commit * Spec improvments * More spec improvments, including resource "availability" * Recursively return inner transaction tree * Lint * No need for ConfirmedRound, so don't deref a nil pointer! * license check * Shut up, dawg. * testing: Fix unit test TestAsyncTelemetryHook_QueueDepth (#2685) Fix the unit test TestAsyncTelemetryHook_QueueDepth * Deprecate `FastPartitionRecovery` from `ConsensusParams` (#3386) ## Summary This PR removes `FastPartitionRecovery` option from consensus parameters. The code now acts as if this value is set to true. Closes algorand/go-algorand-internal#1830. ## Test Plan None. * base64 merge cleanup * Remaking a PR for CI (#3398) * Allow setting manager, reserve, freeze, and clawback at goal asset create * Add e2e tests * Add more tests for goal asset create flags Co-authored-by: Fionna <fionnacst@gmail.com> * Remove the extraneous field type arrays. * bsqrt * acct_holding_get, a unified opcode for account field access * Thanks, dawg * [Other] CircleCI pipeline change for binary uploads (#3381) For nightly builds ("rel/nightly"), we want to have deadlock enabled. For rel/beta and rel/stable, we want to make sure we can build and upload a binary with deadlock disabled so that it can be used for release testing and validation purposes. * signer.KeyDilution need not depend on config package (#3265) crypto package need not depend on config. There is an unnecessary dependency on config. signer.KeyDilution takes the `config.ConsensusParams` as argument to pick the DefaultKeyDilution from it. This introduces dependency from the crypto package to config package. Instead, only the DefaultKeyDilution value can be passed to signer.KeyDilution. * CR and more spec simplification * algodump is a tcpdump-like tool for algod's network protocol (#3166) This PR introduces algodump, a tcpdump-like tool for monitoring algod network messages. * Removing C/crypto dependencies from `data/abi` package (#3375) * Feature Networks pipeline related changes (#3393) Added support for not having certain files in signing script * e2e test for inner transaction appls * testing: Add slightly more coverage to TestAcctUpdatesLookupRetry (#3384) Add slightly more coverage to TestAcctUpdatesLookupRetry * add context to (most) agreement logged writes (#3411) Current agreement code only writes a `context : agreement` to a subset of the logged messages. This change extends the said entry, which would make it easier to pre-process logs entries by their corresponding component. The change in this PR is focused on: 1. make sure that the "root" agreement logger always injects the `context : agreement` argument. 2. change the various locations in the agreement code to use the root agreement logger instead of referring to the application-global instance (`logging.Base()`). * network: faster node shutdown (#3416) During the node shutdown, all the current outgoing connections are being disconnected. Since these connections are web sockets, they require a close connection message to be sent. However, sending this message can take a while, and in situations where the other party has already shut down, we might never get a response. That, in turn, would lead the node waiting until the deadline is reached. The current deadline was 5 seconds. This PR changes the deadline during shutdown to be 50ms. * Give max group size * 16 inner txns, regardless of apps present * Adjust test for allowing 256 inners Co-authored-by: Tsachi Herman <tsachi.herman@algorand.com> Co-authored-by: Tolik Zinovyev <tolik@algorand.com> Co-authored-by: Jack <87339414+algojack@users.noreply.github.com> Co-authored-by: Fionna <fionnacst@gmail.com> Co-authored-by: algobarb <78746954+algobarb@users.noreply.github.com> Co-authored-by: Shant Karakashian <55754073+algonautshant@users.noreply.github.com> Co-authored-by: Nickolai Zeldovich <nickolai@csail.mit.edu> Co-authored-by: Hang Su <87964331+ahangsu@users.noreply.github.com> Co-authored-by: chris erway <51567+cce@users.noreply.github.com>
1 parent a106e83 commit 83bccc5

16 files changed

+82
-76
lines changed

agreement/demux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (d *demux) tokenizeMessages(ctx context.Context, net Network, tag protocol.
122122

123123
o, err := tokenize(raw.Data)
124124
if err != nil {
125-
logging.Base().Warnf("disconnecting from peer: error decoding message tagged %v: %v", tag, err)
125+
d.log.Warnf("disconnecting from peer: error decoding message tagged %v: %v", tag, err)
126126
net.Disconnect(raw.MessageHandle)
127127
d.UpdateEventsQueue(eventQueueTokenizing[tag], 0)
128128
continue

agreement/listener.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616

1717
package agreement
1818

19-
import (
20-
"github.com/algorand/go-algorand/logging"
21-
)
22-
2319
// A listener is a state machine which can handle events, returning new events.
2420
type listener interface {
2521
// T returns the stateMachineTag describing the listener.
@@ -60,17 +56,17 @@ func (l checkedListener) handle(r routerHandle, p player, in event) event {
6056
errs := l.pre(p, in)
6157
if len(errs) != 0 {
6258
for _, err := range errs {
63-
logging.Base().Errorf("%v: precondition violated: %v", l.T(), err)
59+
r.t.log.Errorf("%v: precondition violated: %v", l.T(), err)
6460
}
65-
logging.Base().Panicf("%v: precondition violated: %v", l.T(), errs[0])
61+
r.t.log.Panicf("%v: precondition violated: %v", l.T(), errs[0])
6662
}
6763
out := l.listener.handle(r, p, in)
6864
errs = l.post(p, in, out)
6965
if len(errs) != 0 {
7066
for _, err := range errs {
71-
logging.Base().Errorf("%v: postcondition violated: %v", l.T(), err)
67+
r.t.log.Errorf("%v: postcondition violated: %v", l.T(), err)
7268
}
73-
logging.Base().Panicf("%v: postcondition violated: %v", l.T(), errs[0])
69+
r.t.log.Panicf("%v: postcondition violated: %v", l.T(), errs[0])
7470
}
7571
return out
7672
}

agreement/persistence.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ func persist(log serviceLogger, crash db.Accessor, Round basics.Round, Period pe
8282
return
8383
}
8484

85-
logging.Base().Errorf("persisting failure: %v", err)
85+
log.Errorf("persisting failure: %v", err)
8686
return
8787
}
8888

8989
// reset deletes the existing recovery state from database.
9090
//
9191
// In case it's unable to clear the Service table, an error would get logged.
9292
func reset(log logging.Logger, crash db.Accessor) {
93-
logging.Base().Infof("reset (agreement): resetting crash state")
93+
log.Infof("reset (agreement): resetting crash state")
9494

9595
err := crash.Atomic(func(ctx context.Context, tx *sql.Tx) (err error) {
9696
// we could not retrieve our state, so wipe it
@@ -99,7 +99,7 @@ func reset(log logging.Logger, crash db.Accessor) {
9999
})
100100

101101
if err != nil {
102-
logging.Base().Warnf("reset (agreement): failed to clear Service table - %v", err)
102+
log.Warnf("reset (agreement): failed to clear Service table - %v", err)
103103
}
104104
}
105105

@@ -124,7 +124,7 @@ func restore(log logging.Logger, crash db.Accessor) (raw []byte, err error) {
124124
if err == nil {
125125
// the above call was completed sucecssfully, which means that we've just created the table ( which wasn't there ! ).
126126
// in that case, the table is guaranteed to be empty, and therefore we can return right here.
127-
logging.Base().Infof("restore (agreement): crash state table initialized")
127+
log.Infof("restore (agreement): crash state table initialized")
128128
err = errNoCrashStateAvailable
129129
return
130130
}
@@ -135,7 +135,7 @@ func restore(log logging.Logger, crash db.Accessor) (raw []byte, err error) {
135135
if !reset {
136136
return
137137
}
138-
logging.Base().Infof("restore (agreement): resetting crash state")
138+
log.Infof("restore (agreement): resetting crash state")
139139

140140
// we could not retrieve our state, so wipe it
141141
_, err = tx.Exec("delete from Service")
@@ -149,12 +149,12 @@ func restore(log logging.Logger, crash db.Accessor) (raw []byte, err error) {
149149
row := tx.QueryRow("select count(*) from Service")
150150
err := row.Scan(&nrows)
151151
if err != nil {
152-
logging.Base().Errorf("restore (agreement): could not query raw state: %v", err)
152+
log.Errorf("restore (agreement): could not query raw state: %v", err)
153153
reset = true
154154
return err
155155
}
156156
if nrows != 1 {
157-
logging.Base().Infof("restore (agreement): crash state not found (n = %d)", nrows)
157+
log.Infof("restore (agreement): crash state not found (n = %d)", nrows)
158158
reset = true
159159
noCrashState = true // this is a normal case (we have leftover crash state from an old round)
160160
return errNoCrashStateAvailable
@@ -163,7 +163,7 @@ func restore(log logging.Logger, crash db.Accessor) (raw []byte, err error) {
163163
row = tx.QueryRow("select data from Service")
164164
err = row.Scan(&raw)
165165
if err != nil {
166-
logging.Base().Errorf("restore (agreement): could not read crash state raw data: %v", err)
166+
log.Errorf("restore (agreement): could not read crash state raw data: %v", err)
167167
reset = true
168168
return err
169169
}
@@ -176,7 +176,7 @@ func restore(log logging.Logger, crash db.Accessor) (raw []byte, err error) {
176176
// decode process the incoming raw bytes array and attempt to reconstruct the agreement state objects.
177177
//
178178
// In all decoding errors, it returns the error code in err
179-
func decode(raw []byte, t0 timers.Clock) (t timers.Clock, rr rootRouter, p player, a []action, err error) {
179+
func decode(raw []byte, t0 timers.Clock, log serviceLogger) (t timers.Clock, rr rootRouter, p player, a []action, err error) {
180180
var t2 timers.Clock
181181
var rr2 rootRouter
182182
var p2 player
@@ -185,7 +185,7 @@ func decode(raw []byte, t0 timers.Clock) (t timers.Clock, rr rootRouter, p playe
185185

186186
err = protocol.DecodeReflect(raw, &s)
187187
if err != nil {
188-
logging.Base().Errorf("decode (agreement): error decoding retrieved state (len = %v): %v", len(raw), err)
188+
log.Errorf("decode (agreement): error decoding retrieved state (len = %v): %v", len(raw), err)
189189
return
190190
}
191191

@@ -307,9 +307,9 @@ func (p *asyncPersistenceLoop) loop(ctx context.Context) {
307307
// sanity check; we check it after the fact, since it's not expected to ever happen.
308308
// performance-wise, it takes approximitly 300000ns to execute, and we don't want it to
309309
// block the persist operation.
310-
_, _, _, _, derr := decode(s.raw, s.clock)
310+
_, _, _, _, derr := decode(s.raw, s.clock, p.log)
311311
if derr != nil {
312-
logging.Base().Errorf("could not decode own encoded disk state: %v", derr)
312+
p.log.Errorf("could not decode own encoded disk state: %v", derr)
313313
}
314314
}
315315
}

agreement/persistence_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ func TestAgreementSerialization(t *testing.T) {
4343
encodedBytes := encode(clock, router, status, a)
4444

4545
t0 := timers.MakeMonotonicClock(time.Date(2000, 0, 0, 0, 0, 0, 0, time.UTC))
46-
clock2, router2, status2, a2, err := decode(encodedBytes, t0)
46+
log := makeServiceLogger(logging.Base())
47+
clock2, router2, status2, a2, err := decode(encodedBytes, t0, log)
4748
require.NoError(t, err)
4849
require.Equalf(t, clock, clock2, "Clock wasn't serialized/deserialized correctly")
4950
require.Equalf(t, router, router2, "Router wasn't serialized/deserialized correctly")
@@ -77,10 +78,10 @@ func BenchmarkAgreementDeserialization(b *testing.B) {
7778

7879
encodedBytes := encode(clock, router, status, a)
7980
t0 := timers.MakeMonotonicClock(time.Date(2000, 0, 0, 0, 0, 0, 0, time.UTC))
80-
81+
log := makeServiceLogger(logging.Base())
8182
b.ResetTimer()
8283
for n := 0; n < b.N; n++ {
83-
decode(encodedBytes, t0)
84+
decode(encodedBytes, t0, log)
8485
}
8586
}
8687

agreement/proposalManager.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ package agreement
1818

1919
import (
2020
"fmt"
21-
22-
"github.com/algorand/go-algorand/logging"
2321
)
2422

2523
// A proposalManager is a proposalMachine which applies relay rules to incoming
@@ -71,7 +69,7 @@ func (m *proposalManager) handle(r routerHandle, p player, e event) event {
7169
r = m.handleNewPeriod(r, p, e.(thresholdEvent))
7270
return emptyEvent{}
7371
}
74-
logging.Base().Panicf("proposalManager: bad event type: observed an event of type %v", e.t())
72+
r.t.log.Panicf("proposalManager: bad event type: observed an event of type %v", e.t())
7573
panic("not reached")
7674
}
7775

agreement/proposalStore.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ package agreement
1818

1919
import (
2020
"fmt"
21-
22-
"github.com/algorand/go-algorand/logging"
2321
)
2422

2523
// An blockAssembler contains the proposal data associated with some
@@ -289,7 +287,7 @@ func (store *proposalStore) handle(r routerHandle, p player, e event) event {
289287
case newRound:
290288
if len(store.Assemblers) > 1 {
291289
// TODO this check is really an implementation invariant; move it into a whitebox test
292-
logging.Base().Panic("too many assemblers")
290+
r.t.log.Panic("too many assemblers")
293291
}
294292
for pv, ea := range store.Assemblers {
295293
if ea.Filled {
@@ -347,7 +345,7 @@ func (store *proposalStore) handle(r routerHandle, p player, e event) event {
347345
se.Payload = ea.Payload
348346
return se
349347
}
350-
logging.Base().Panicf("proposalStore: bad event type: observed an event of type %v", e.t())
348+
r.t.log.Panicf("proposalStore: bad event type: observed an event of type %v", e.t())
351349
panic("not reached")
352350
}
353351

agreement/proposalTracker.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"fmt"
2121

2222
"github.com/algorand/go-algorand/data/basics"
23-
"github.com/algorand/go-algorand/logging"
2423
)
2524

2625
// A proposalSeeker finds the vote with the lowest credential until freeze() is
@@ -180,7 +179,7 @@ func (t *proposalTracker) handle(r routerHandle, p player, e event) event {
180179
return se
181180
}
182181

183-
logging.Base().Panicf("proposalTracker: bad event type: observed an event of type %v", e.t())
182+
r.t.log.Panicf("proposalTracker: bad event type: observed an event of type %v", e.t())
184183
panic("not reached")
185184
}
186185

agreement/pseudonode.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ func (t pseudonodeProposalsTask) execute(verifier *AsyncVoteVerifier, quit chan
481481

482482
payloads, votes := t.node.makeProposals(t.round, t.period, t.participation)
483483
fields := logging.Fields{
484-
"Context": "Agreement",
485484
"Type": logspec.ProposalAssembled.String(),
486485
"ObjectRound": t.round,
487486
"ObjectPeriod": t.period,

agreement/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func MakeService(p Parameters) *Service {
9393

9494
s.parameters = parameters(p)
9595

96-
s.log = serviceLogger{Logger: p.Logger}
96+
s.log = makeServiceLogger(p.Logger)
9797

9898
// GOAL2-541: tracer is not concurrency safe. It should only ever be
9999
// accessed by main state machine loop.
@@ -191,7 +191,7 @@ func (s *Service) mainLoop(input <-chan externalEvent, output chan<- []action, r
191191
var err error
192192
raw, err := restore(s.log, s.Accessor)
193193
if err == nil {
194-
clock, router, status, a, err = decode(raw, s.Clock)
194+
clock, router, status, a, err = decode(raw, s.Clock, s.log)
195195
if err != nil {
196196
reset(s.log, s.Accessor)
197197
} else {

agreement/trace.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,12 @@ type serviceLogger struct {
497497
logging.Logger
498498
}
499499

500+
func makeServiceLogger(log logging.Logger) serviceLogger {
501+
return serviceLogger{log.With("Context", "Agreement")}
502+
}
503+
500504
func (log serviceLogger) with(e logspec.AgreementEvent) serviceLogger {
501505
fields := logging.Fields{
502-
"Context": "Agreement",
503506
"Type": e.Type.String(),
504507
"Round": e.Round,
505508
"Period": e.Period,

0 commit comments

Comments
 (0)