Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 10 additions & 20 deletions data/transactions/logic/assembler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,28 +626,13 @@ func assembleWithTrace(text string, ver uint64) (*OpStream, error) {
return &ops, err
}

func lines(s string, num int) (bool, string) {
if num < 1 {
return true, ""
}
found := 0
for i := 0; i < len(s); i++ {
if s[i] == '\n' {
found++
if found == num {
return true, s[0 : i+1]
}
}
}
return false, s
}

func summarize(trace *strings.Builder) string {
truncated, msg := lines(trace.String(), 50)
Comment thread
jannotti marked this conversation as resolved.
if !truncated {
return msg
all := trace.String()
if strings.Count(all, "\n") < 50 {
return all
}
return msg + "(trace truncated)\n"
lines := strings.Split(all, "\n")
return strings.Join(lines[:20], "\n") + "\n(some trace elided)\n" + strings.Join(lines[len(lines)-20:], "\n")
}

func testProg(t testing.TB, source string, ver uint64, expected ...expect) *OpStream {
Expand Down Expand Up @@ -1713,6 +1698,11 @@ pushint 1
block BlkFeesCollected
pushint 1
block BlkBonus
global PayoutsEnabled
global PayoutsGoOnlineFee
global PayoutsPercent
global PayoutsMinBalance
global PayoutsMaxBalance
`, AssemblerMaxVersion)
for _, names := range [][]string{GlobalFieldNames[:], TxnFieldNames[:], blockFieldNames[:]} {
for _, f := range names {
Expand Down
10 changes: 10 additions & 0 deletions data/transactions/logic/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -3732,6 +3732,16 @@ func (cx *EvalContext) globalFieldToValue(fs globalFieldSpec) (sv stackValue, er
case GenesisHash:
gh := cx.SigLedger.GenesisHash()
sv.Bytes = gh[:]
case PayoutsEnabled:
sv.Uint = boolToUint(cx.Proto.Payouts.Enabled)
case PayoutsGoOnlineFee:
sv.Uint = cx.Proto.Payouts.GoOnlineFee
case PayoutsPercent:
sv.Uint = cx.Proto.Payouts.Percent
case PayoutsMinBalance:
sv.Uint = cx.Proto.Payouts.MinBalance
case PayoutsMaxBalance:
sv.Uint = cx.Proto.Payouts.MaxBalance
default:
return sv, fmt.Errorf("invalid global field %s", fs.field)
}
Expand Down
16 changes: 14 additions & 2 deletions data/transactions/logic/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ func makeTestProto(opts ...protoOpt) *config.ConsensusParams {

MaxBoxSize: 1000,
BytesPerBoxReference: 100,

Payouts: config.ProposerPayoutRules{
Enabled: true,
GoOnlineFee: 3,
Percent: 4,
MinBalance: 5,
MaxBalance: 6,
},
}
for _, opt := range opts {
if opt != nil { // so some callsites can take one arg and pass it in
Expand Down Expand Up @@ -1236,7 +1244,11 @@ global GenesisHash; len; int 32; ==; &&
`

const globalV11TestProgram = globalV10TestProgram + `
// No new globals in v11
global PayoutsEnabled; assert
global PayoutsGoOnlineFee; int 3; ==; assert
global PayoutsPercent; int 4; ==; assert
global PayoutsMinBalance; int 5; ==; assert
global PayoutsMaxBalance; int 6; ==; assert
`

func TestGlobal(t *testing.T) {
Expand All @@ -1260,7 +1272,7 @@ func TestGlobal(t *testing.T) {
8: {CallerApplicationAddress, globalV8TestProgram},
9: {CallerApplicationAddress, globalV9TestProgram},
10: {GenesisHash, globalV10TestProgram},
11: {GenesisHash, globalV11TestProgram},
11: {PayoutsMaxBalance, globalV11TestProgram},
}
// tests keys are versions so they must be in a range 1..AssemblerMaxVersion plus zero version
require.LessOrEqual(t, len(tests), AssemblerMaxVersion+1)
Expand Down
26 changes: 26 additions & 0 deletions data/transactions/logic/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,21 @@ const (
// GenesisHash is the genesis hash for the network
GenesisHash

// PayoutsEnabled is whether block proposal payouts are enabled
PayoutsEnabled

// PayoutsGoOnlineFee is the fee required in a keyreg transaction to make an account incentive eligible
PayoutsGoOnlineFee

// PayoutsPercent is the percentage of transaction fees in a block that can be paid to the block proposer.
PayoutsPercent

// PayoutsMinBalance is the minimum algo balance an account must have to receive block payouts (in the agreement round).
PayoutsMinBalance

// PayoutsMaxBalance is the maximum algo balance an account can have to receive block payouts (in the agreement round).
PayoutsMaxBalance

invalidGlobalField // compile-time constant for number of fields
)

Expand Down Expand Up @@ -603,6 +618,17 @@ var globalFieldSpecs = [...]globalFieldSpec{
{AssetOptInMinBalance, StackUint64, modeAny, 10,
"The additional minimum balance required to opt-in to an asset."},
{GenesisHash, StackBytes32, modeAny, 10, "The Genesis Hash for the network."},

{PayoutsEnabled, StackBoolean, modeAny, incentiveVersion,
Comment thread
gmalouf marked this conversation as resolved.
"Whether block proposal payouts are enabled."},
{PayoutsGoOnlineFee, StackUint64, modeAny, incentiveVersion,
"The fee required in a keyreg transaction to make an account incentive eligible."},
{PayoutsPercent, StackUint64, modeAny, incentiveVersion,
"The percentage of transaction fees in a block that can be paid to the block proposer."},
{PayoutsMinBalance, StackUint64, modeAny, incentiveVersion,
"The minimum algo balance an account must have in the agreement round to receive block payouts in the proposal round."},
{PayoutsMaxBalance, StackUint64, modeAny, incentiveVersion,
"The maximum algo balance an account can have in the agreement round to receive block payouts in the proposal round."},
}

func globalFieldSpecByField(f GlobalField) (globalFieldSpec, bool) {
Expand Down
11 changes: 8 additions & 3 deletions data/transactions/logic/fields_string.go

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